#K69707. Find an Integer Repeated Exactly Twice

    ID: 33146 Type: Default 1000ms 256MiB

Find an Integer Repeated Exactly Twice

Find an Integer Repeated Exactly Twice

Given a sequence of n positive integers, find and output the first integer (in order of occurrence) that appears exactly twice in the sequence. It is guaranteed that there is at least one integer with exactly two occurrences.

If there are multiple integers that appear exactly twice, output the one whose second occurrence appears earliest in the sequence.

You may refer to the condition \(\text{count}(x) = 2\) for an integer \(x\) to satisfy the requirement.

inputFormat

The input is given from stdin and consists of two lines:

  1. The first line contains an integer n, the number of integers in the sequence.
  2. The second line contains n space-separated positive integers.

outputFormat

Print to stdout a single integer which is the first integer that appears exactly twice in the given sequence.

## sample
5
3 2 3 6 1
3

</p>