Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60

ans = 0
for j in range(digit):
  o = 0
  for i in a:
    if (i >> j) & 1:
      o += 1
  ans += (o*(n-o)*2**j)
  ans %= MOD
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0    
for j in range(digit):
  ans += (o[j]*z[j]*pow(2,j,MOD))
print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

ans = 0
for j in range(digit):
  for i in a:
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
  ans += (o[j]*z[j]*2**j)
  ans %= MOD
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0    
for j in range(digit):
  ans += (o[j]*z[j]*pow(2,j,MOD))
print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0
for j in range(digit):
  ans += (o[j]*z[j]*2**j)
  ans %= MOD
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0    
for j in range(digit):
  ans += (o[j]*z[j]*pow(2,j,MOD))
print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0
for j in range(digit):
  ans += (o[j]*z[j]*2**j)
print(ans % MOD)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0    
for j in range(digit):
  ans += (o[j]*z[j]*pow(2,j,MOD))
print(ans % MOD)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0
for j in range(digit):
  ans += (o[j]*z[j]*2**j
print(ans % MOD)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0    
for j in range(digit):
  ans += (o[j]*z[j]*pow(2,j,MOD))
print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0    
for j in range(digit):
  ans += (o[j]*z[j]*pow(2,j,MOD))
print(ans % MOD)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0    
for j in range(digit):
  ans += (o[j]*z[j]*pow(2,j,MOD))
print(ans % MOD)

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

ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    ans += a[i] ^ a[j]

print(ans % (10 ** 9 + 7))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0    
for j in range(digit):
  ans += (o[j]*z[j]*pow(2,j,MOD))
print(ans % MOD)