from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
b = [ [0]*n for i in range(60) ]
acc = [ [0]*n for i in range(60) ]
sums = [0]*60
for bit in range(60):
    for i in range(n):
        b[bit][i] = (a[i]>>bit)&1
    acc[bit][n-1] = b[bit][n-1]
    for i in range(n-2,-1,-1):
        acc[bit][i] = acc[bit][i+1] + b[bit][i]
    for i in range(n-1):
        sums[bit] += acc[bit][i+1] if b[bit][i]==0 else \
                     (n-1-i-acc[bit][i+1])

x = 0
for bit in range(60):
    x = (x + sums[bit]*(2**bit)) % R
print(x)
