MOD = 10**9+7
N = int(input())
Data = list(map(int,input().split()))
sum0 = sum(Data)
sum1 = sum(Data)*N*2 
sum2 = 0
for v in Data:
    sum2 += (v & sum0)
ans = ((sum1 - 2*N*sum2) // 2) % MOD
print(ans)
