#K61117. First Duplicate Bib Number

    ID: 31239 Type: Default 1000ms 256MiB

First Duplicate Bib Number

First Duplicate Bib Number

Given a list of bib numbers, determine the first duplicate that appears when traversing the list from left to right. If no duplicate exists, output -1.

In more formal terms, if the input list is \(a_1, a_2, \dots, a_n\), you need to find the smallest index \(j\) for which there exists an index \(i < j\) such that \(a_i = a_j\). If such indices do not exist, the answer is \(-1\).

inputFormat

The input is read from stdin and consists of two lines. The first line contains an integer (n), the number of bib numbers. The second line contains (n) space-separated integers.

outputFormat

Output to stdout a single integer, which is the first duplicate bib number encountered in the list. If no duplicate exists, output (-1).## sample

5
8 3 5 7 3
3

</p>