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

Задача 25969. 3rd low


From digital sensors, the computer receives information about the characteristics of the physical process. The result of each measurement is an integer.

You are invited to write an efficient, including memory-used, program that will output the third largest (counting from the minimum) value of the measurement. If multiple dimensions have the same values, they are counted as one dimension. If the value you are looking for does not exist (for example, when all dimension values ​​are equal), then you need to print the character "#". Please note that the number of measurements can be very large.

The input to the program in the first line is the total number of N measurement values.
Each of the following N lines contains an integer. It is guaranteed that \(N>0\), i.e. there is always at least one dimension.
 

 

Examples
# Input Output
1 5
100
10
100
10
100
#