N = int(eval(input()))

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



#Aiを二進数として，各けたを見れば良い？1の個数*0の個数



ans =0

mod =pow(10,9)+7



#Aiは最大で2^60-1

Max = 61



 #i桁目を見る

for i in range(Max):

    count = 0#その桁での1の数

    for j in range(N):

        if(A[j]>>i & 1)==1:

            count+=1

    ans+=count*(N-count)*pow(2,i)

    ans = ans%mod

print(ans)
import sys

input = sys.stdin.readline



def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))



def main():

    mod=10**9+7

    N=I()

    M=65

    A=LI()

    cnt=[0]*M

    

    for i in range(N):

        a=A[i]

        for j in range(M):

            if a>>j & 1:

                cnt[j]+=1

                

    ans=0

    for i in range(M):

        a=cnt[i]

        b=N-a

        ans=(ans + a*b*pow(2,i,mod))%mod

        

    print(ans)

                



main()

N = int(eval(input()))
A = list(map(int, input().split()))
# Aiを二進数として，各けたを見れば良い？1の個数*0の個数
ans = 0
mod = pow(10, 9) + 7
# Aiは最大で2^60-1
Max = 61
# i桁目を見る
for i in range(Max):
    count = 0  # その桁での1の数
    for j in range(N):
        if (A[j] >> i & 1) == 1:
            count += 1
    ans += count * (N - count) * pow(2, i)
    ans = ans % mod
print(ans)

import sys

input = sys.stdin.readline


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def main():
    mod = 10**9 + 7
    N = I()
    M = 65
    A = LI()
    cnt = [0] * M
    for i in range(N):
        a = A[i]
        for j in range(M):
            if a >> j & 1:
                cnt[j] += 1
    ans = 0
    for i in range(M):
        a = cnt[i]
        b = N - a
        ans = (ans + a * b * pow(2, i, mod)) % mod
    print(ans)


main()

-N = int(eval(input())) -A = list(map(int, input().split())) -# Aiを二進数として，各けたを見れば良い？1の個数*0の個数 -ans = 0 -mod = pow(10, 9) + 7 -# Aiは最大で2^60-1 -Max = 61 -# i桁目を見る -for i in range(Max): -    count = 0  # その桁での1の数 -    for j in range(N): -        if (A[j] >> i & 1) == 1: -            count += 1 -    ans += count * (N - count) * pow(2, i) -    ans = ans % mod -print(ans) +import sys + +input = sys.stdin.readline + + +def I(): +    return int(eval(input())) + + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def main(): +    mod = 10**9 + 7 +    N = I() +    M = 65 +    A = LI() +    cnt = [0] * M +    for i in range(N): +        a = A[i] +        for j in range(M): +            if a >> j & 1: +                cnt[j] += 1 +    ans = 0 +    for i in range(M): +        a = cnt[i] +        b = N - a +        ans = (ans + a * b * pow(2, i, mod)) % mod +    print(ans) + + +main()