import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
L=len(format(max(a),"b"))
s=[0]*L
for i in range(n):
  c=format(a[i], 'b').zfill(L)
  for j in range(L)[::-1]:
    s[j]+=int(c[j])
ans=0
for i in range(len(s))[::-1]:
  ans+=2**(i)*(s[L-i-1])*(n-s[L-i-1])
  ans%=mod
print(ans)
