M = 60
p = [2 ** i for i in range(M)]
dp = [0] * M

res = 0
n = int(input())
for i, x in enumerate(map(int, input().split())):
    for j in range(M):
        b = x & p[j]
        if b:
            cnt = i - dp[j]
            dp[j] += 1
        else:
            cnt = dp[j]
        res += cnt * p[j]
        res %= int(1e9 + 7)
print(res)
