n=int(input())
a = input()
d = []
x = []
r = []

for i in range(0, len(a)):
    if a[i] != ' ':
        d.append(int(a[i]))
d.reverse()
for i in range(0, len(d)):
    d.count(d[i])
    x.append(d.count(d[i])) #[d[i],

for i in range(0, len(x)):
    if x[i] not in r:
        r.append(x[i])

print(r[0])
print(r[1])
