import itertools

input()

def to_bin(s):
  return bin(int(s))[2:]
  
a_list = list(map(to_bin, input().split(" ")))
s_list = []

for a in itertools.combinations(a_list, 2):
  n = len(a[0]) if len(a[0]) > len(a[1]) else len(a[1])
  a0 = a[0].zfill(n)
  a1 = a[1].zfill(n)
  s = ""
  for a_0, a_1 in zip(a0, a1):
    if a_0 == "1" and a_1 == "0":
      s += "1"
    elif a_0 == "0" and a_1 == "1":
      s += "1"
    else:
      s += "0"
  s_list.append(int(s, 2))
print(sum(s_list))
