import numpy as np
n = int(input())
a = list(map(int, input().split()))
p = 7 + 10**9


# TLE
def xor(ai, a): return list(map(lambda x: x^ai, a))
def naive():
    ans = 0
    for i in range(n-1):
        ans += sum(xor(a[i], a[i+1:]))
    print(ans % p)


# MAIN
b = [tuple(map(int, format(i, "060b"))) for i in a]
bits1 = np.array(b)
bits0 = bits1 ^ 1

accum1 = np.add.accumulate(bits1[::-1])[::-1]
accum0 = np.add.accumulate((bits0)[::-1])[::-1]

sum1 = bits1[:-1] * accum0[1:]
sum0 = bits0[:-1] * accum1[1:]

sumall = np.sum(sum1, axis=0) + np.sum(sum0, axis=0)
ans = sumall * (2 ** np.array(list(range(60)), np.int64))[::-1] % p

print(np.sum(ans) % p)