P26746 [AtCoder] Rare Number
提高
题目描述

Problem Description

Given an integer sequence \( A = (A_1, A_2, \ldots, A_N) \) of length \( N \).

Output the integer that appears the least frequently in \( A \). If there are multiple such integers, output the smallest one among them.

Input Format

The input is given from the standard input in the following format:

\( N \) \( A_1 \) \( A_2 \) \( \cdots \) \( A_N \)

Output Format

Output the integer that appears the least frequently in \( A \). If there are multiple such integers, output the smallest one among them.

Sample Input and Output

Sample Input #1

3
3 4 3

Sample Output #1

4

Sample Input #2

5
4 4 8 2 5

Sample Output #2

2

Sample Input #3

8
8 8 7 7 6 6 5 5

Sample Output #3

5

Notes/Hints

Constraints

  • \( 1 \leq N \leq 100 \).
  • \( 1 \leq A_i \leq 2000 \) (\( 1 \leq i \leq N \)).
  • All input values are integers.

Sample Explanation 1

In \( A \), \( 3 \) appears \( 2 \) times and \( 4 \) appears \( 1 \) time. No other integers appear. Since \( 4 \) appears the least frequently, output \( 4 \).

Sample Explanation 2

In \( A \), \( 2 \) appears \( 1 \) time, \( 4 \) appears \( 2 \) times, \( 5 \) appears \( 1 \) time, and \( 8 \) appears \( 1 \) time. No other integers appear. The integers that appear the least frequently are \( 2, 5, \) and \( 8 \). Therefore, output the smallest one among them, which is \( 2 \).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 4 3
样例输出
4