#CCBCHBAHAI0000082. Giá trị lặp đầu tiên - miền 0..1000 (First Repeated Value in the Range 0..1000)
Giá trị lặp đầu tiên - miền 0..1000 (First Repeated Value in the Range 0..1000)
First Repeated Value in the Range 0..1000
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given with , scan left to right. Let
if such an index exists. Print , the first value encountered for the second time. If no value repeats, print -1.
Input
The first line contains . The second line contains integers in .
Output
Print the first repeated value, or -1 if there is none.
Subtask
Subtask 1 (20 points): , .
Subtask 2 (30 points): , .
Subtask 3 (50 points): , .
Example
Input
7
4 1 7 4 1 9 7
Output
4
Explanation
The output follows directly from the mathematical definition above.