import sys
input = sys.stdin.readline

def main():
    MOD = 10**9 + 7
    
    N = int(input())
    A = list(map(int, input().split()))
    
    import numpy as np
    
    count = np.zeros((N+1, 60, 2), dtype='int')
    
    b = np.zeros(60, dtype='int')
    b[0] = 1
    for i in range(1, 60): b[i] = b[i-1] * 2 % MOD
    
    for i in range(1, N+1):
        count[i] = np.copy(count[i-1])
        a = A[i-1]
        for j in range(60):
            count[i][j][a%2] += 1
            a >>= 1
        
    ans = 0
    
    n = np.zeros(60, dtype='int')
    for i in range(1, N):
        c = count[N]-count[i]
        a = A[i-1]
        for j in range(60):
            n[j] = c[j][0] if a % 2 else c[j][1]
            a >>= 1
        ans = (ans + np.sum(n*b)) % MOD
        
    print(ans)
    
if __name__ == '__main__':
    main()    