import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()] , dtype=np.int64)
a_ = list(map(int, input().split()))
m = 10**9+7
ans = 0
for k in range(60):
    b = (a>>k) & 1
    res = np.count_nonzero(b)
    ans += res*(n-res)*2**k
print(ans%m)