import sys

input=sys.stdin.readline

n=int(eval(input()))

lists=list(map(int,input().split()))

length=61

use=[0 for i in range(61)]

a,b=divmod(n,9)

anslist=[0 for i in range(a+1)]

for  j in range(n):

    k=format(lists[j],"0%ib"%length)

    k=k[::-1]

    p,q=divmod(j,9)

    if p>a:

        anslist.append(str(k))

    else:

        anslist[p]+=int(k)

answer=0

for some in anslist:

    some=str(some)

    some=some.zfill(61)

    for j in range(61):

        if int(some[j])!=0:

            use[j]+=int(some[j])



for j in range(61):

    answer+=(2**j)*use[j]*(n-use[j])%(10**9+7)

print((answer%(10**9+7)))

#昔はtleの回答、今は通る？

import sys

input=sys.stdin.readline

n=int(eval(input()))

lists=list(map(int,input().split()))

aa=[0 for i in range(n)]

bb=[0 for i in range(n)]

length=61

use=[0 for i in range(61)]

for  j in range(n):

    k=format(lists[j],"0%ib"%length)

    k=k[::-1]

    aa[j]=k[:30]  

    bb[j]=k[30:]

for p in aa:    

    for some in range(30):

        use[some]+=int(p[some])

for q in bb:    

    for some in range(31):

        use[some+30]+=int(q[some])

answer=0



for j in range(61):

    answer+=(2**j)*use[j]*(n-use[j])%(10**9+7)

print((answer%(10**9+7)))

import sys

input = sys.stdin.readline
n = int(eval(input()))
lists = list(map(int, input().split()))
length = 61
use = [0 for i in range(61)]
a, b = divmod(n, 9)
anslist = [0 for i in range(a + 1)]
for j in range(n):
    k = format(lists[j], "0%ib" % length)
    k = k[::-1]
    p, q = divmod(j, 9)
    if p > a:
        anslist.append(str(k))
    else:
        anslist[p] += int(k)
answer = 0
for some in anslist:
    some = str(some)
    some = some.zfill(61)
    for j in range(61):
        if int(some[j]) != 0:
            use[j] += int(some[j])
for j in range(61):
    answer += (2**j) * use[j] * (n - use[j]) % (10**9 + 7)
print((answer % (10**9 + 7)))

# 昔はtleの回答、今は通る？
import sys

input = sys.stdin.readline
n = int(eval(input()))
lists = list(map(int, input().split()))
aa = [0 for i in range(n)]
bb = [0 for i in range(n)]
length = 61
use = [0 for i in range(61)]
for j in range(n):
    k = format(lists[j], "0%ib" % length)
    k = k[::-1]
    aa[j] = k[:30]
    bb[j] = k[30:]
for p in aa:
    for some in range(30):
        use[some] += int(p[some])
for q in bb:
    for some in range(31):
        use[some + 30] += int(q[some])
answer = 0
for j in range(61):
    answer += (2**j) * use[j] * (n - use[j]) % (10**9 + 7)
print((answer % (10**9 + 7)))

+# 昔はtleの回答、今は通る？ +aa = [0 for i in range(n)] +bb = [0 for i in range(n)] -a, b = divmod(n, 9) -anslist = [0 for i in range(a + 1)] -    p, q = divmod(j, 9) -    if p > a: -        anslist.append(str(k)) -    else: -        anslist[p] += int(k) +    aa[j] = k[:30] +    bb[j] = k[30:] +for p in aa: +    for some in range(30): +        use[some] += int(p[some]) +for q in bb: +    for some in range(31): +        use[some + 30] += int(q[some]) -for some in anslist: -    some = str(some) -    some = some.zfill(61) -    for j in range(61): -        if int(some[j]) != 0: -            use[j] += int(some[j])