def d(A, d):
    return (A >> d) & 1

def main():
    N = int(input())
    A = [int(i) for i in input().split()]

    _s = 0
    S = [[0]*60 for _ in range(N)]
    S[0] = [d(A[0],j) for j in range(60)]
    for i in range(1,N):
        for j in range(60):
            S[i][j] += S[i-1][j] + d(A[i], j)
    res = 0
    for i in range(1,N):
        for j in range(60):
            if d(A[i],j) == 0:
                res += (S[i-1][j])*(2**j)
                res %= (10**9+7)
            else:
                res += (i - S[i-1][j])*(2**j)
                res %= (10**9+7)
    print(res % (10**9+7))
    # print(S)
    # dp = [[0]*N for _ in range(60)]
    # dp[0] = [d(S[i], 0) for i in range(N)]
    # for i in range(1,60):
    #     for j in range(N):
    #         dp[i][j] = dp[i][j-1] ^ d(S[j-1] ^ (A[j] if (N-1)%2==0 else 0), i) ^ (1 if dp[i-1][j-1] > dp[i-1][j] else 0)
    # res = 0
    # for a in reversed(dp[N-1]):
    #     res <<= 1
    #     res += a
    # print(res)
main()