n=int(input())
numbers=input().split()
nums=list(map(int,numbers))
#print(nums)
mx=0
for num in nums:
    if num>mx:
        mx=num
#print(mx)
j=0
ans=0
while 2**j<=mx:
    sm=0
    for num in nums:
        sm+= num>>j &1
    ans+=(sm)*(n-sm)*2**j
    j=j+1
#print(ans)
print(ans%1000000007)