import sys input = sys.stdin.buffer.readline n = int(input()) A = list(map(int, input().split())) temp = 1 for a in A: nx = temp << a # print("temp", bin(temp), "nx", bin(nx)) temp ^= nx ans = 0 keta = 0 while temp: if temp % 2: ans ^= keta temp //= 2 keta += 1 print(ans)