import sys
input = sys.stdin.readline
M = 10**9+7
n = int(input())
l = list(map(int,input().split()))
x = max(l)
s = bin(x)
u = len(s)-2
o = [0]*u
for i in l:
    x = bin(i)
    x = x[2:]
    a = list(x)
    d = u - len(a)
    a = (["0"] * d) + a
    j = 0
    while(j < len(o)):
        if a[j] == "1":
            o[j] = o[j]+1

        j = j+1

cnt = 0
z = len(o)*[0]
for i in range(len(o)):
    z[i] = len(l)-o[i]


for r in range(len(l)-1):
    i = l[r]
    x = bin(i)
    x = x[2:]
    a = list(x)
    d = u-len(a)
    a = (["0"]*d)+a
    j = u-1
    y = 0
    while(j > -1):
        if a[y] == "0":
            z[y] = z[y]-1
            cnt = (cnt+((2**j)*o[y])%M)%M

        if a[y] == "1":
            o[y] = o[y]-1
            cnt = (cnt + ((2 ** j) * z[y]) % M) % M

        y = y+1
        j = j-1

print(cnt)