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 .
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 the maximum value in a single line. If there is no such and , just output .