#入力値処理
n = int(input())
data = [int(s) for s in input().split()]

bindata = []

for value in data:
  tmp = format(value,'b').zfill(60)  
  bindata.append(tmp)

#各桁の1の個数を格納
numlist = [0] * 60

for rowdata in bindata:
  for j in range(60):
    if rowdata[j] == '1':
      numlist[59-j] += 1
ans = 0

#各桁の1の個数と0の個数の積の和を求める
for i in range(60):
  ans += numlist[i] * (n-numlist[i]) * (2 ** i)
ans = ans % (10**9 + 7)
print(ans)






"""
ans = 0

for i in range(n-1):
  for j in range(i,n):
    ans = ans +  int(bin(data[i] ^ data[j]),0)
ans = ans % (10 ** 9 + 7)

print(int(ans))
"""