Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
aaa = list(map(int, input().split()))

MOD = 10 ** 9 + 7
ans = 0
m = 1
ans = 0
for _ in range(60):
    one_count = 0
    for a in aaa:
        one_count += a & m
    one_count //= m
    zero_count = n - one_count
    ans = (ans + one_count * zero_count * m) % MOD
    m *= 2
        
print(ans)


Fixed submission:
n = int(input())
aaa = list(map(int, input().split()))

MOD = 10 ** 9 + 7
ans = 0
m = 1
ans = 0
for _ in range(60):
    one_count = sum(a & m for a in aaa)
    one_count //= m
    zero_count = n - one_count
    ans = (ans + one_count * zero_count * m) % MOD
    m *= 2
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# import math
# import fractions
# import numpy as np

MOD = 10 ** 9 + 7

def solve(N, A):
    # for i, a in enumerate(A):
    #     A[i] = bin(a)
    # print(A)
    
    ans = 0
    for i in range(N - 1):
        for j in range(i+1, N):
          ans += (A[i] ^ A[j]) % MOD

    return ans % MOD

# S = input()
N = int(input())
# H, N = map(int, input().split())
A = list(map(int, input().split()))
# B = [int(input()) for _ in range(n)]
# A = []
# B = []
# for _ in range(N):
#     a, b = list(map(int, input().split()))
#     A.append(a)
#     B.append(b)

print(solve(N, A))


Fixed submission:
n = int(input())
aaa = list(map(int, input().split()))

MOD = 10 ** 9 + 7
ans = 0
m = 1
ans = 0
for _ in range(60):
    one_count = sum(a & m for a in aaa)
    one_count //= m
    zero_count = n - one_count
    ans = (ans + one_count * zero_count * m) % MOD
    m *= 2
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# import math
# import fractions
import numpy as np

MOD = 10 ** 9 + 7

def solve(N, A):
    # for i, a in enumerate(A):
    #     A[i] = bin(a)
    # print(A)
    
    B = []
    for i in range(N - 1):
        for j in range(i+1, N):
          B.append(np.bitwise_xor(A[i], A[j]) % MOD)  

    return sum(B) % MOD

# S = input()
N = int(input())
# H, N = map(int, input().split())
A = list(map(int, input().split()))
# B = [int(input()) for _ in range(n)]
# A = []
# B = []
# for _ in range(N):
#     a, b = list(map(int, input().split()))
#     A.append(a)
#     B.append(b)

print(solve(N, A))


Fixed submission:
n = int(input())
aaa = list(map(int, input().split()))

MOD = 10 ** 9 + 7
ans = 0
m = 1
ans = 0
for _ in range(60):
    one_count = sum(a & m for a in aaa)
    one_count //= m
    zero_count = n - one_count
    ans = (ans + one_count * zero_count * m) % MOD
    m *= 2
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# import math
# import fractions
# import numpy as np

MOD = 10 ** 9 + 7

def solve(N, A):
    # for i, a in enumerate(A):
    #     A[i] = bin(a)
    # print(A)
    
    B = []
    for i in range(N - 1):
        for j in range(i+1, N):
          B.append((A[i] ^ A[j]) % MOD)  

    return sum(B) % MOD

# S = input()
N = int(input())
# H, N = map(int, input().split())
A = list(map(int, input().split()))
# B = [int(input()) for _ in range(n)]
# A = []
# B = []
# for _ in range(N):
#     a, b = list(map(int, input().split()))
#     A.append(a)
#     B.append(b)

print(solve(N, A))


Fixed submission:
n = int(input())
aaa = list(map(int, input().split()))

MOD = 10 ** 9 + 7
ans = 0
m = 1
ans = 0
for _ in range(60):
    one_count = sum(a & m for a in aaa)
    one_count //= m
    zero_count = n - one_count
    ans = (ans + one_count * zero_count * m) % MOD
    m *= 2
        
print(ans)