from collections import Counter n = int(input()) a = list(map(int, input().split())) c = Counter(a) for i in range(1<<20): if c[i] < 2: print(i) break