def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A

def digits2int(c, L, MOD):
    base = 0
    for i in range(L):
        factor = (1 << i) % MOD
        f = (factor * c[i]) % MOD
        base = (base + f) % MOD
    return base


def solve(N, A, L=60, MOD=10**9+7):
    # j桁目のビットが1であるものの数を、累積和として記憶
    count_ones = [[0 for j in range(L+1)] for i in range(N+1)]
    for i in range(N):
        for j in range(L):
            count_ones[i+1][j] = count_ones[i][j] + ((A[i] >> j) & 1)
    # A[i] と A[j] (i<j) のxorをとる
    modsum = 0
    for i in range(N-1):
        c = [0 for j in range(L)]
        for j in range(L):
            if ((A[i] >> j) & 1) == 0:
                c[j] = count_ones[N][j] - count_ones[i+1][j]
            else:
                c[j] = (N-i-1) - (count_ones[N][j] - count_ones[i+1][j])
        modsum = (modsum + digits2int(c, L, MOD)) % MOD
    return modsum


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))