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)))
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)))

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)))

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)))

+import sys + +input = sys.stdin.readline