import itertools
def main():
    N = int(input())
    A = list(map(int, input().split()))
    sum = 0
    for i in itertools.combinations(A, 2):
        sum += i[0]^i[1]
    print(sum)
if __name__ == '__main__':
    main()
