import sys

def main():
    readline = sys.stdin.buffer.readline
    N = int(readline())
    A = list(map(int, readline().split()))

    MOD = 10**9 + 7

    ans = 0
    M = len(bin(max(A)))-2
    B = [bin(A[i])[2:].zfill(M) for i in range(N)]
    bin1 = [0 for _ in range(M)]

    for d in range(M):
        for b in B:
            if b[-(d+1)] == "1":
                bin1[-(d+1)] += 1
        ans += pow(2, d, MOD) * bin1[-(d+1)] * (N - bin1[-(d+1)])
        ans %= MOD

    print(ans)

if __name__ == "__main__":
    main()
