n | max_num = float('-inf') | n | max1 = float('-inf') |
| second_max = float('-inf') | | max2 = float('-inf') |
| while True: | | while True: |
| num = int(input()) | | num = int(input()) |
| if num == 0: | | if num == 0: |
| break | | break |
t | if num > max_num: | t | if num > max1: |
| second_max = max_num | | max2 = max1 |
| max_num = num | | |
| elif num > second_max and num != max_num: | | |
| second_max = num | | max1 = num |
| | | elif num > max2 and num < max1: |
| | | max2 = num |
| if second_max != float('-inf'): | | if max2 != float('-inf'): |
| print(second_max) | | print(max2) |
| else: | | else: |
| print('NO') | | print('NO') |