# -*- coding: utf-8 -*-
import math
import datetime
import itertools

# 入力
N = int(input())
S = str(input())
#N, A, B = map(int, input().split())
#A, B, C = map(int, input().split())

Z = (10 ** 9) + 7
list = list(map(int, list(set(S.split()))))

sum = 0
for v in itertools.combinations(list, 2):
    #print(v)
    sum += v[0] ^ v[1]
print (sum%Z)