Under construction

Still being built. Things may change

Rare Number

Interview

Time limit2sMemory limit1024 MB

Summary
Given a list of N integers, print the value that occurs the fewest times, breaking ties by choosing the smallest value.
Level

Easy3 of 10

Topics
Hash map, Array, Implementation
Solved
No attempts yet

Problem

An integer sequence A = (A1, A2, …, AN) of length N is given.

Print the integer that appears in A the fewest times. If more than one integer qualifies, print the smallest such integer.

Input

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

N
A1 A2 … AN

Output

Print the integer that appears in A the fewest times. If more than one integer qualifies, print the smallest such integer.

Constraints

  • 1 ≦ N ≦ 100.
  • 1 ≦ Ai ≦ 2000 (1 ≦ i ≦ N).
  • All input values are integers.

Examples3

  1. Example 1

    Input
    3
    3 4 3
    
    Expected output
    4
    
  2. Example 2

    Input
    5
    4 4 8 2 5
    
    Expected output
    2
    
  3. Example 3

    Input
    8
    8 8 7 7 6 6 5 5
    
    Expected output
    5