Hide

Problem E
Penultimate Ice Cream

/problems/penultimateicecream/file/statement/en/img-0001.jpg
Public Domain (CC0)

Sara is at her favorite ice cream store. She would really like to get the most expensive item on the menu (because it will contain the most ice cream, of course). However, if her friends notice that she bought the most expensive item on the menu, they will assume she has plenty of money and start bugging her to buy ice cream for them too. So she decides to settle for the second most expensive item on the menu, which will still contain plenty of ice cream but will not attract the attention of her friends.

Input

The first line of the input is an integer $n$, with $2 \leq n \leq 1\, 000$. The second line contains $n$ space-separated integers, which are the prices of items on the menu. Each price is between $1$ and $1\, 000$, inclusive. All the prices will be distinct.

Output

Output a single line containing the price of the second most expensive item on the menu.

Sample Input 1 Sample Output 1
10
4 8 2 1 6 9 22 13 18 5
18

Please log in to submit a solution to this problem

Log in