n = int(eval(input()))

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



l.sort(reverse=True)

kmax = len(format(l[0], 'b'))



l0 = [0]*kmax

l1 = [0]*kmax



for i in range(n):

  a = format(l[i], 'b')

  a = ''.join(list(reversed(a)))

  for j in range(kmax):

    if j > len(a)-1:

      l0[j] += 1

    elif a[j] == '0':

      l0[j] += 1

    else:

      l1[j] += 1



ans = 0

for k in range(kmax):

  ans += l0[k]*l1[k]*(2**k)

  ans %= 10**9+7

print(ans)
n = int(eval(input()))

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



mod = 10**9+7

X = [0]*62

for i in range(n):

    a = A[i]

    b = format(a, 'b')

    b = list(b)

    b.reverse()

    for j in range(len(b)):

        if b[j] == '1':

            X[j] += 1

ans = 0

for i in range(62):

    x = X[i]

    y = n-X[i]

    #print(i, x, y)

    ans += x*y*pow(2, i, mod)

ans %= mod

print(ans)

n = int(eval(input()))
l = list(map(int, input().split()))
l.sort(reverse=True)
kmax = len(format(l[0], "b"))
l0 = [0] * kmax
l1 = [0] * kmax
for i in range(n):
    a = format(l[i], "b")
    a = "".join(list(reversed(a)))
    for j in range(kmax):
        if j > len(a) - 1:
            l0[j] += 1
        elif a[j] == "0":
            l0[j] += 1
        else:
            l1[j] += 1
ans = 0
for k in range(kmax):
    ans += l0[k] * l1[k] * (2**k)
    ans %= 10**9 + 7
print(ans)

n = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
X = [0] * 62
for i in range(n):
    a = A[i]
    b = format(a, "b")
    b = list(b)
    b.reverse()
    for j in range(len(b)):
        if b[j] == "1":
            X[j] += 1
ans = 0
for i in range(62):
    x = X[i]
    y = n - X[i]
    # print(i, x, y)
    ans += x * y * pow(2, i, mod)
ans %= mod
print(ans)

-l = list(map(int, input().split())) -l.sort(reverse=True) -kmax = len(format(l[0], "b")) -l0 = [0] * kmax -l1 = [0] * kmax +A = list(map(int, input().split())) +mod = 10**9 + 7 +X = [0] * 62 -    a = format(l[i], "b") -    a = "".join(list(reversed(a))) -    for j in range(kmax): -        if j > len(a) - 1: -            l0[j] += 1 -        elif a[j] == "0": -            l0[j] += 1 -        else: -            l1[j] += 1 +    a = A[i] +    b = format(a, "b") +    b = list(b) +    b.reverse() +    for j in range(len(b)): +        if b[j] == "1": +            X[j] += 1 -for k in range(kmax): -    ans += l0[k] * l1[k] * (2**k) -    ans %= 10**9 + 7 +for i in range(62): +    x = X[i] +    y = n - X[i] +    # print(i, x, y) +    ans += x * y * pow(2, i, mod) +ans %= mod