from collections import Counter n = int(input()) A = list(map(int, input().split())) counter = Counter(A) for i in range(n): if counter[i] >= 2: continue if counter[i] == 1 and counter[i + 1] > 0: print(i + 1) break print(i) break