def xor(l1=[]):
  
  s2=0
  n=len(l1)

  mod=1e9+7
  for i in range(64):
    s1=0
    one=0
    zero=0
    for j in range(n):
      if l1[j]%2==0:
        zero+=1
      else:
        one+=1
      
      l1[j]=l1[j]//2

    #print(one)
    #print(zero)
    #print(2**i)
    s1=one*zero*(2**i)
    #print(s1)
    s2=(s2%mod+s1%mod)%mod
  return s2%mod

n = int(input())
arr = input()   
l = list(map(int,arr.split(' ')))
val=xor(l)
print(int(val))