n = int(input())
a = list(map(int, input().split()))

cnt = [[[0, 0] for _ in range(n + 1)] for _ in range(60)]
for i in range(60): # <= 2^60
    for j, v in enumerate(a):
        if v & (1 << i):
            cnt[i][j][1] = cnt[i][j - 1][1] + 1
            cnt[i][j][0] = cnt[i][j - 1][0]
        else:
            cnt[i][j][1] = cnt[i][j - 1][1]
            cnt[i][j][0] = cnt[i][j - 1][0] + 1

result = 0
for p, delete in enumerate(a):
    for i, cs in enumerate(cnt):
        if delete & (1 << i):
            target = 0
        else:
            target = 1

        result += (cs[n - 1][target] - cs[p - 1][target]) * (1 << i)
print(result % (10**9 + 7))
