MAXINARR - Maximum element of an array

no tags 

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

hide comments
Vivek Vardhan: 2012-03-13 10:26:59

:D :D :D

Andrés Mejía-Posada: 2012-03-13 05:39:17

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
Alex Anderson: 2012-03-13 05:22:21

This problem should not be in classical.

Rocker3011: 2012-03-14 14:30:07

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

david_8k: 2012-03-14 14:30:04

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
Luis Arguello: 2012-03-13 05:22:21

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
Rishi Mukherje: 2012-03-13 05:22:21

lov u python..:)

Aradhya: 2012-03-13 05:22:21

hahahahaha :D :D :D :D hahaha

BOND: 2012-03-13 05:22:21

@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
RAJDEEP GUPTA: 2012-03-13 05:22:21

how is it even possible to solve it in less than O(n)? we have to read the elements at least!


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