import math
from unittest import removeResult

n = int(input())
numbers = [int(x) for x in input().split(" ")]
total = sum(numbers)

max_power = math.ceil(math.log(total, 2))
# print(max_power + 1)

current_power = 0

result = 0

for i in range(max_power + 1):
    # print(current_power)
    current_num = 2 ** (current_power + 1)
    current_total = 0
    for num in numbers:
        current_total += num % current_num
        if (current_total >= (current_num / 2)):
            result += 2 ** current_power
            break

    current_power += 1

print(result)