def main():
    import sys
    mod = int(1e9+7)
    input=sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    #S[0]は使わない
    S = [[0]*60 for _ in range(N)]

    tmp = A[-1]
    idx = 0
    while tmp > 0:
        if tmp%2:
            S[-1][idx] += 1
        idx += 1
        tmp //= 2

    for i in range(N-2, 0, -1):
        for j in range(60):
            S[i][j] = S[i+1][j]
        tmp = A[i]
        idx = 0
        while tmp > 0:
            if tmp % 2:
                S[i][idx] += 1
            idx += 1
            tmp //= 2

    ans = 0
    for i in range(N-1):
        tmp = A[i]
        idx = 0
        while tmp > 0:
            if tmp % 2:
                ans += ((N-1-i)-S[i+1][idx])*2**idx

            else:
                ans += S[i+1][idx]*2**idx

            idx += 1
            tmp //= 2

        for x in S[i+1][idx:]:
            ans += x*2**idx%mod
            idx += 1

        ans %= mod

    print(ans)

if __name__ == '__main__':
    main()