Buggy python submission (verdict: Runtime Error):
n, *A = map(int, open(0).read().split())
A = [a%mod for a in A]
mod = 10**9 + 7
ans = 0
d = 1
while any(A):
  c = 0
  for i in range(n):
    q, r = divmod(A[i], 2)
    A[i] = q
    c += r
  ans += c*(n-c) * d
  ans %= mod
  d *= 2
print(ans % mod)

Fixed submission:
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
ans = 0
for i in range(bit):
    nb_1 = sum(((a >> i) & 1 for a in A))
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, *A = map(int, open(0).read().split())
mod = 10**9 + 7
ans = 0
d = 1
while any(A):
  c = 0
  for i in range(n):
    q, r = divmod(A[i], 2)
    A[i] = q
    c += r
  ans += c*(n-c) * d
  ans %= mod
  d *= 2
print(ans % mod)

Fixed submission:
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
ans = 0
for i in range(bit):
    nb_1 = sum(((a >> i) & 1 for a in A))
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
B = [(format(a, '0{}b'.format(bit)))[::-1] for a in A]
ans = 0
for i in range(bit):
    nb_1 = sum([int(b[i]) for b in B])
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)

Fixed submission:
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
ans = 0
for i in range(bit):
    nb_1 = sum(((a >> i) & 1 for a in A))
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
B = [(format(a, '0{}b'.format(bit)))[::-1] for a in A]
ans = 0
for i in range(bit):
    nb_1 = sum([int(b[i]) for b in B])
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)

Fixed submission:
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
ans = 0
for i in range(bit):
    nb_1 = sum(((a >> i) & 1 for a in A))
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
A = sorted(list(map(int, inputs[1].split())))
MOD = 10 ** 9 + 7

ans = 0
for i in range(n-1):
    for j in range(i, n):
        ans += A[i] ^ A[j]
        ans %= MOD
print(ans)

Fixed submission:
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
ans = 0
for i in range(bit):
    nb_1 = sum(((a >> i) & 1 for a in A))
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)