Buggy python submission (verdict: Time Limit Exceeded):
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum(1 for a in A if ( (a >> k) & 1))
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(int(ans))

Fixed submission:
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(60):
    N1 = 0
    N1 = sum(1 for a in A if ( (a >> k) & 1))
    N0 = N-N1
    ans += (((1<<k)) *N0 *N1)
    ans %= M    

print(int(ans))

Fixed submission:
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(60):
    N1 = 0
    for a in A:
        if (a >> k) & 1:
            N1 += 1
    N0 = N-N1
    ans += (((1<<k)) *N0 *N1)
    ans %= M    

print(int(ans))

Fixed submission:
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(60):
    N1 = 0
    N1 = sum(( (a >> k) & 1) for a in A )
    N0 = N-N1
    ans += (((1<<k)%M) *N0 *N1) % M

ans %= M    
print(int(ans))

Fixed submission:
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

maxA = max(A)
K = len(str(bin(maxA)))-2
ans = 0
for k in range(K):
    N1 = 0
    N1 = sum(( (a >> k) & 1) for a in A )
    N0 = N-N1
    ans += (((1<<k)%M) *N0 *N1) % M

ans %= M    
print(int(ans))


Fixed submission:
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

maxA = max(A)
K = len(str(bin(maxA)))-2
ans = 0
for k in range(K):
    N1 = 0
    for a in A:
        N1 += int( (a >> k) & 1)
    N0 = N-N1
    ans += (((1<<k)%M) *N0 *N1) % M

ans %= M    
print(int(ans))

Fixed submission:
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

maxA = max(A)
K = len(str(bin(maxA)))-2
ans = 0
for k in range(K):
    N1 = 0
    bk = 1<<k
    for i in range(0,N):
#        N1 += ( (A[i] >> k) & 1)
        N1 += (A[i] & bk)
    N1 //= bk
    N0 = N-N1
    ans += (((1<<k)%M) *N0 *N1) % M

ans %= M    
print(int(ans))

Fixed submission:
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

maxA = max(A)
K = len(str(bin(maxA)))-2
ans = 0
for k in range(K):
    N1 = 0
    for i in range(0,N):
        N1 += ( (A[i] >> k) & 1)
    N0 = N-N1
    ans += (((1<<k)%M) *N0 *N1) % M

ans %= M    
print(int(ans))

Fixed submission:
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i, a in enumerate(A[:-1]):
    for b in A[i+1:]:
        ans = (ans + (a^b))%M

print(ans)

Fixed submission:
M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(ans)