n = int(input()) A = list(map(int, input().split())) A.sort() cnt = [0] * (10 ** 5 + 1) for a in A: cnt[a] += 1 tot = 0 for i in range(10 ** 5): tot += cnt[i] if cnt[i] == 0: print(i) break elif cnt[i] == 1: if tot == n: print(i) else: print(i + 1) break