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