def solve():
    from sys import stdin
    f_i = stdin
    
    mod = 10 ** 9 + 7
    
    N = int(f_i.readline())
    A = list(map(int, f_i.readline().split()))
    
    ans = 0
    b = 1
    while A:
        next_A = []
        
        bit_cnt = 0
        
        for A_i in A:
            if A_i & 1:
                bit_cnt += 1
            A_i >>= 1
            if A_i:
                next_A.append(A_i)
        
        ans += b * bit_cnt * (N - bit_cnt)
        ans %= mod
        
        b *= 2
        A = next_A[:]
        
    print(ans)

solve()