n = int(input())
A = [int(i) for i in input().split()]

s = {}
mx = 0
for a in A:
    cnt = 0
    while a != 0:
        # print(cnt,a)
        if(a&1)==1:
            if s.get(cnt+1)==None:
                s[cnt+1]=1
            else:
                s[cnt+1] += 1
        cnt+=1
        a = a >> 1
    mx = max(mx,cnt)
ans = 0
for i in range(mx+1):
    # print("a",2**(i-1)*s.get(i,0)*(n-s.get(i,0)))
    # print("b",s.get(i,0))
    # print("c",(n-s.get(i,0)))
    ans += 2**(i-1)*s.get(i,0)*(n-s.get(i,0))
ans = ans % (10**9+7)
print(int(ans))
# print(s)
