MAXINARR - Maximum element of an array

Given an array of n integers, find the value of its maximum element.

Input

The input consists of several test cases.

Each test case is described in two lines. The first line contains n, the size of the array (1 <= n <= 106). The second line contains n integers separated by one or more spaces. Each integer in the array will be between -109 and 109, inclusive.

The last line of the input contains a single 0 and should not be processed.

Output

For each test case, write the maximum element in the array on a single line.

Example

Input:
4
1 2 3 4
2
-1 0
3
-1000000000 0 1000000000
0

Output:
4
0
1000000000

Added by:Andrés Mejía-Posada
Date:2012-03-12
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Introduction to Programming Course, EAFIT University

hide comments
2012-03-13 10:26:59 Vivek Vardhan
:D :D :D
2012-03-13 05:39:17 Andrés Mejía-Posada

The test data has been fixed.

All submissions have been rejudged. Sorry for the mistake!

Also, the problem has been moved to Tutorial.

Last edit: 2012-03-13 05:47:06
2012-03-13 05:22:21 Alex Anderson
This problem should not be in classical.
2012-03-14 14:30:07 Rocker3011
This is pretty much an insult because i was killing myselft doing this problem as the problem statemen says, and it is not even close to what it should be, if you are thinking to read until n==0 you are screw you have to read till EOF and check if n==0 you will put this line in c and c++ return 0; else you will process the test cases

the problem statement is wrong, and it should be fixed quickly, an easy problem becoming a head ache just because someone wrote it wrong and didn´t give all the information

FIX IT FOR REAL
2012-03-14 14:30:04 david_8k
Please, if you are going to set a problem, you can at least have the guts to tell us WHAT ARE WE EXPECTED TO DO... This kind of problems get me sick, you hope we're some kind of ... I don't know, psychics to figure out what we're expected to do in such a problem.

THERE'S AN INPUT FILE THAT DOESN'T HAVE A 0 IN IT, READ TILL EOF.

THAT SHOULD BE THE OUTPUT DETAILS...

Please, try to set more serious or elaborated problems... If you can't do it, then don't set problems.

Last edit: 2012-03-13 13:35:19
2012-03-13 05:22:21 Luis Arguello
Why is this problem in classical? It should be moved to tutorial. O(n) gave me AC

Last edit: 2012-03-12 23:08:05
2012-03-13 05:22:21 Rishi Mukherje
lov u python..:)
2012-03-13 05:22:21 Aradhya
hahahahaha :D :D :D :D hahaha
2012-03-13 05:22:21 BOND
@all:
Mitch Schwartz is right. Read till end of file meanwhile check for n==0.
it should be fixed.

Last edit: 2012-03-12 17:37:53
2012-03-13 05:22:21 RAJDEEP GUPTA
how is it even possible to solve it in less than O(n)? we have to read the elements at least!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.