Sticks Problem
Easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Xuanxuan has sticks of different length. One day, she puts all her sticks in a line, represented by . After measuring the length of each stick , she finds that for some sticks and , each stick placed between and is longer than but shorter than .
Now given the length of , you are required to find the maximum value .
Input
Contains multiple test cases. Each case contains two lines. First line is a single integer , indicating the number of sticks. Second line contains different positive integers (not larger than ), indicating the length of each stick in order.
Output
Output the maximum value in a single line. If there is no such and , just output .
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 24%