Zane the ledger master watches over the cotton rows of Whitewick's stores of stamps. A careful computation stands between order and chaos. Task: Read n integers and print the first value that appears twice (the value whose second occurrence has the smallest index). If all are distinct print -1. Input format: First line: n. Second line: n space-separated integers. Output format: Print the first repeated value, or -1. Constraints: 1 <= n <= 386; 0 <= a[i] <= 1000; answers fit a signed 64-bit integer.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 386; 0 <= a[i] <= 1000; answers fit a signed 64-bit integer.
