#abc329b. B - Next

B - Next

Score : 200200 points

问题描述

给定 NN 个整数 A1,A2,,ANA_1, A_2, \ldots, A_N。找出其中不是最大值的最大整数。

本问题的约束条件保证了答案的存在性。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given NN integers A1,A2,,ANA_1, A_2, \ldots, A_N. Find the largest among those integers that are not the largest.

The constraints of this problem guarantee that the answer exists.

Constraints

  • 2N1002 \leq N \leq 100
  • 1Ai1001 \leq A_i \leq 100
  • It is not the case that all A1,A2,,ANA_1, A_2, \ldots, A_N are equal.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \ldots ANA_N

Output

Print the answer.

Sample Input 1

5
2 1 3 3 2

Sample Output 1

2

The largest integer among 2,1,3,3,22,1,3,3,2 is 33.

The integers that are not 33 among 2,1,3,3,22,1,3,3,2 are 2,1,22,1,2, among which the largest is 22.

Sample Input 2

4
4 3 2 1

Sample Output 2

3

Sample Input 3

8
22 22 18 16 22 18 18 22

Sample Output 3

18

update @ 2024/3/10 01:53:50