The second maximum

The second maximum. The sequence consists of distinct positive integers and ends with the number 0. Determine the value of the second largest element in this sequence. It is guaranteed that the sequence has at least two elements.

Test Case Input (Sequence) Expected Output
1 1
2
3
0
2
2 10
5
8
0
8
3 7
3
5
4
6
0
6