Олимпиадный тренинг

Задача 44772. The second maximum in the tree


Задача

Темы: Деревья

Display the second largest element in the constructed tree. It is guaranteed that there is one.


Input

You are given a sequence of integers ending in zero. Zero itself is not included in the sequence.


Output

Print the answer to the problem.

 
Examples
# Input Output
1
7 3 2 1 9 5 4 6 8 0
8