n=int(input())
l=list(map(int,input().split()))
x="{0:063b}"
for i in range(n):
l[i] = x.format(l[i])# we are converting every element to it's binary form
#with 63 length.
c=[0]*63
for i in l:
for j in range(63):
c[j]+=int(i[j]) # counting number of 1 for every bits.
# now for every bit, number of 1 is c[i] and number of 0 is n-c[i].
#no we have to make our ans, so for any bit if number of 0 is greater than number of
#number of 1 then we have to choose 1 , if no of 1 is gretaer than we will choose
# 0 and in case if both no of 1 and 0 are equal we can choose either 1 or 0 ,
# but we will choose 0 , as we have to find minimum x.
ans=""
for i in range(63):
if c[i]>=n-c[i]:
ans+='0'
else:
ans+='1'
print(int(ans,2))
bj1pbnQoaW5wdXQoKSkKbD1saXN0KG1hcChpbnQsaW5wdXQoKS5zcGxpdCgpKSkKeD0iezA6MDYzYn0iCmZvciBpIGluIHJhbmdlKG4pOgogICAgbFtpXSA9IHguZm9ybWF0KGxbaV0pIyB3ZSBhcmUgY29udmVydGluZyBldmVyeSBlbGVtZW50IHRvIGl0J3MgYmluYXJ5IGZvcm0KICAgICAgICAgICAgICAgICAgICAgICAgICN3aXRoIDYzIGxlbmd0aC4KCmM9WzBdKjYzCmZvciBpIGluIGw6CiAgICBmb3IgaiBpbiByYW5nZSg2Myk6CiAgICAgICAgY1tqXSs9aW50KGlbal0pICMgY291bnRpbmcgbnVtYmVyIG9mIDEgZm9yIGV2ZXJ5IGJpdHMuCiMgbm93IGZvciBldmVyeSBiaXQsIG51bWJlciBvZiAxIGlzIGNbaV0gYW5kIG51bWJlciBvZiAwIGlzIG4tY1tpXS4KI25vIHdlIGhhdmUgdG8gbWFrZSBvdXIgYW5zLCBzbyBmb3IgYW55IGJpdCBpZiBudW1iZXIgb2YgMCBpcyBncmVhdGVyIHRoYW4gbnVtYmVyIG9mCiNudW1iZXIgb2YgMSB0aGVuIHdlIGhhdmUgdG8gY2hvb3NlIDEgLCBpZiBubyBvZiAxIGlzIGdyZXRhZXIgdGhhbiB3ZSB3aWxsIGNob29zZQojIDAgYW5kIGluIGNh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