#python3

n = int(eval(input()))

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

mod = 10**9+7

md = len(bin(max(a)))-2

ans = 0

for d in range(md):

    cnt1 = sum([1 for i in a if ((i>>d)&1)]) 

    ans += cnt1 * (n-cnt1) * (1<<d)          

    ans %= mod                              

    

print((ans%mod))

#python3

import numpy as np

n=int(eval(input()))

a=np.array([int(i) for i in input().split()])

mod=int(1e9+7)

ans=0

for k in range(60):

  b = (a>>k)&1

  m = np.count_nonzero(b)

  ans += m*(n-m)*2**k

print((ans%mod))
# python3
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
md = len(bin(max(a))) - 2
ans = 0
for d in range(md):
    cnt1 = sum([1 for i in a if ((i >> d) & 1)])
    ans += cnt1 * (n - cnt1) * (1 << d)
    ans %= mod
print((ans % mod))

# python3
import numpy as np

n = int(eval(input()))
a = np.array([int(i) for i in input().split()])
mod = int(1e9 + 7)
ans = 0
for k in range(60):
    b = (a >> k) & 1
    m = np.count_nonzero(b)
    ans += m * (n - m) * 2**k
print((ans % mod))

+import numpy as np + -a = list(map(int, input().split())) -mod = 10**9 + 7 -md = len(bin(max(a))) - 2 +a = np.array([int(i) for i in input().split()]) +mod = int(1e9 + 7) -for d in range(md): -    cnt1 = sum([1 for i in a if ((i >> d) & 1)]) -    ans += cnt1 * (n - cnt1) * (1 << d) -    ans %= mod +for k in range(60): +    b = (a >> k) & 1 +    m = np.count_nonzero(b) +    ans += m * (n - m) * 2**k