N = int(input()) cnt = [0] * (10**5+10) A = list(map(int,input().split())) for i in range(N): cnt[A[i]] += 1 for i in range(10**5+5): if cnt[i] < 2: print(i) exit()