from sys import stdin
import numpy as np
import math
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 10**9 + 7
    n = I()
    a = np.array(LI())
    ans = 0
    for i in range(61):
        c0 = sum((a>>i)&1)
        c1 = n-c0
        ans += (c0*c1*2**i)%mod
    ans %= mod
    print(ans)