import numpy as np

mod=10**9+7

N=int(eval(input()))

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

ans=0

for i in range(60):

  b=np.count_nonzero(A>>i&1)

  ans+=(2**i)*b*(N-b)

  ans%=mod

  

print(ans)
import numpy as np 

# 初期入力

mod = 10**9 +7

ans =0

N =int(eval(input()))

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

A_np =np.array(A,dtype=np.int64)



# xor 各桁の０と1の数を求め

for i in range(60):

    c =np.count_nonzero(A_np &1)

    ans +=2**i*c*(N-c)

    A_np >>=1

print((ans %mod))
import numpy as np

mod = 10**9 + 7
N = int(eval(input()))
A = np.array(list(map(int, input().split())))
ans = 0
for i in range(60):
    b = np.count_nonzero(A >> i & 1)
    ans += (2**i) * b * (N - b)
    ans %= mod
print(ans)

import numpy as np

# 初期入力
mod = 10**9 + 7
ans = 0
N = int(eval(input()))
A = list(map(int, input().split()))
A_np = np.array(A, dtype=np.int64)
# xor 各桁の０と1の数を求め
for i in range(60):
    c = np.count_nonzero(A_np & 1)
    ans += 2**i * c * (N - c)
    A_np >>= 1
print((ans % mod))

+# 初期入力 +ans = 0 -A = np.array(list(map(int, input().split()))) -ans = 0 +A = list(map(int, input().split())) +A_np = np.array(A, dtype=np.int64) +# xor 各桁の０と1の数を求め -    b = np.count_nonzero(A >> i & 1) -    ans += (2**i) * b * (N - b) -    ans %= mod -print(ans) +    c = np.count_nonzero(A_np & 1) +    ans += 2**i * c * (N - c) +    A_np >>= 1 +print((ans % mod))