n = int(input())
a = [int(_) for _ in input().split()]
M = max(a)
p = len(format(M, 'b'))
l = [[0 for _ in range(n)] for _ in range(p)]
for i in range(n):
    a_s = format(a[i], '0' + str(p) + 'b')
    for c in range(p):
        l[c][i] = int(a_s[c])
# for i in range(p):
#     print(l[i])
s = [[0 for _ in range(n+1)] for _ in range(p)]
for i in range(p):
    for j in range(n):
        s[i][j+1] = s[i][j] + l[i][j]
# for i in range(p):
#     print(s[i])
ans = 0
for j in range(n-1):
    for i in range(p):
        if l[i][j] == 1:
            ans += ((2**(p - i - 1)) * ((n - j - 1) - (s[i][n] - s[i][j+1]))) % ((10**9) + 7)
        else:
            ans += ((2**(p - i - 1)) * (s[i][n] - s[i][j+1])) % ((10**9) + 7)
        ans = ans % ((10**9) + 7)
print(ans)
