After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: the photo which gets most likes wins. If multiple photoes get most likes, the winner is the photo that gets this number first.

Help guys determine the winner photo by the records of likes.
The first line of the input contains a single integer *n* (1 ≤ *n* ≤ 1000) — the total likes to the published photoes. 

The second line contains *n* positive integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 1 000 000), where *a*<sub class="lower-index">*i*</sub> is the identifier of the photo which got the *i*-th like.
In the first test sample the photo with id 1 got two likes (first and fifth), photo with id 2 got two likes (third and fourth), and photo with id 3 got one like (second). 

Thus, the winner is the photo with identifier 2, as it got:
 -  more likes than the photo with id 3; -  as many likes as the photo with id 1, but the photo with the identifier 2 got its second like earlier.
5
1 3 2 2 1
2
9
100 200 300 200 100 300 300 100 200
300
1
5
5
1
1000000
1000000
5
1 3 4 2 2
2
10
2 1 2 3 1 5 8 7 4 8
2
7
1 1 2 2 2 3 3
2
12
2 3 1 2 3 3 3 2 1 1 2 1
3
15
7 6 8 4 9 8 7 3 4 6 7 5 4 2 8
7
15
100 200 300 500 300 400 600 300 100 200 400 300 600 200 100
300
10
677171 677171 677171 677171 672280 677171 677171 672280 672280 677171
677171
15
137419 137419 531977 438949 137419 438949 438949 137419 438949 531977 531977 531977 438949 438949 438949
438949
20
474463 517819 640039 640039 640039 640039 474463 474463 474463 640039 640039 474463 474463 425567 474463 517819 640039 474463 517819 517819
474463
40
119631 119631 772776 119631 658661 119631 108862 524470 125132 700668 69196 844949 154577 108862 108862 108862 597344 940938 989698 108862 154577 69196 125132 687080 940938 125132 69196 69196 125132 566152 953083 406319 380068 119631 154577 125132 413984 69196 154577 154577
108862
5
1 1 1000000 1000000 1000000
1000000
5
1000000 1 1 1000000 1
1
10
1 1 1000000 1000000 1000000 1 1000000 1 1 1000000
1
8
1000000 1000000 1 1 1 1000000 1000000 1
1000000
1
1
1
2
1 1
1
2
1000000 1
1000000
2
1 1000000
1
2
1000000 1000000
1000000
3
1 1 1
1
3
1 1 2
1
3
1 2 1
1
3
2 1 1
1
4
1 1000000 1000000 1
1000000
n = int(input())
urutan_like= list(map(int, input(). split()))
banyak_like_per_post = [0]*1000000
yang_menang = -1
foto_pemenang = 0

for i in range (len(urutan_like)):
  banyak_like_per_post [urutan_like[i]] += 1
  if banyak_like_per_post [urutan_like [i]] > yang_menang:
    yang_menang = banyak_like_per_post[urutan_like[i]]
    foto_pemenang = urutan_like[i]

print (foto_pemenang)
	  					    	      	 				 	 	