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

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

o = o[::-1]
z = z[::-1]
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
    a = a[::-1]
    j = u - 1
    #print(o,"lo")
    #print(z,"lo")
    while(j > -1):
        if a[j] == "1":
            o[j] = o[j] - 1

        j = j - 1

    j = u-1
    #print(a)
    #print(o)
    while(j > -1):
        if a[j] == "0":
            z[j] = z[j]-1
            cnt = (cnt+((2**j)*o[j]))%M

        j = j-1

    j = u-1
    #print(cnt)
    #print(z)
    while (j > -1):
        if a[j] == "1":
            cnt = (cnt + ((2 ** j) * z[j])) % M

        j = j - 1

    #print(cnt)

print(cnt)