Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))  # O(N)
p = len(format(max(A), 'b')) # O(N)
digit = ['0' + str(p) + 'b'] * N
S = list(map(format, A, digit))  # O(N)

r = [0] * p
for s in S:
  for j in range(p):
    r[j] += int(s[j])

ans = 0
for j in range(p):
  ans += r[-(j+1)] * (N - r[-(j+1)]) * (2 ** j)

print(ans % 1000000007)

Fixed submission:
import numpy as np 
N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

res = 0
for bit in range(60):
  c = int((A & 1).sum())
  res += c * (N - c) * (1 << bit)
  A >>= 1

print(res % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))  # O(N)
p = len(format(max(A), 'b')) # O(N)
digit = ['0' + str(p) + 'b'] * N
S = list(map(format, A, digit))  # O(N)

r = [0] * p
for s in S:
  for j in range(p):
    r[j] += int(s[j])

ans = 0
for j in range(p):
  ans += r[-(j+1)] * (N - r[-(j+1)]) * (2 ** j)

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

Fixed submission:
import numpy as np 
N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

res = 0
for bit in range(60):
  c = int((A & 1).sum())
  res += c * (N - c) * (1 << bit)
  A >>= 1

print(res % 1000000007)

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

p = len(format(max(A), 'b'))
digit = '0' + str(p) + 'b'
#S = list(map(format, A, digit))

r = [0] * p
for a in A:
  s = format(a, digit)
  for j in range(p):
    r[j] += int(s[j])

res = 0
for j in range(p):
  res += r[j] * (N - r[j]) * (2 ** (p-1-j))

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

Fixed submission:
import numpy as np 
N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

res = 0
for bit in range(60):
  c = int((A & 1).sum())
  res += c * (N - c) * (1 << bit)
  A >>= 1

print(res % 1000000007)

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

p = len(format(max(A), 'b'))
digit = '0' + str(p) + 'b'
#S = list(map(format, A, digit))

r = [0] * p
for a in A:
  for j in range(p):
    s = format(a, digit)
    r[j] += int(s[j])

res = 0
for j in range(p):
  res += r[j] * (N - r[j]) * (2 ** (p-1-j))

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

Fixed submission:
import numpy as np 
N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

res = 0
for bit in range(60):
  c = int((A & 1).sum())
  res += c * (N - c) * (1 << bit)
  A >>= 1

print(res % 1000000007)

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

p = len(format(max(A), 'b'))
digit = ['0' + str(p) + 'b'] * N
S = list(map(format, A, digit))

r = [0] * p
for s in S:
  for j in range(p):
    r[j] += int(s[j])

res = 0
for j in range(p):
  res += r[j] * (N - r[j]) * (2 ** (p-1-j))

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

Fixed submission:
import numpy as np 
N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

res = 0
for bit in range(60):
  c = int((A & 1).sum())
  res += c * (N - c) * (1 << bit)
  A >>= 1

print(res % 1000000007)

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

p = len(format(max(A), 'b'))
digit = '0' + str(p) + 'b'

r = [0] * p
for i in range(N):
  tmp = format(A[i], digit)
  #print(tmp)
  for j in range(p):
    r[j] += int(tmp[j])

#print(r)
s = 0
for j in range(p):
  s += r[j] * (N - r[j]) * (2 ** (p-1-j))

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

Fixed submission:
import numpy as np 
N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

res = 0
for bit in range(60):
  c = int((A & 1).sum())
  res += c * (N - c) * (1 << bit)
  A >>= 1

print(res % 1000000007)

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

r = [0] * 60
for i in range(N):
  tmp = format(A[i], '060b')
  #print(tmp)
  for j in range(60):
    r[j] += int(tmp[j])

s = 0
for j in range(60):
  s += r[j] * (N - r[j]) * (2 ** (59-j))
  

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

#print(bin(10**9 + 7))

Fixed submission:
import numpy as np 
N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

res = 0
for bit in range(60):
  c = int((A & 1).sum())
  res += c * (N - c) * (1 << bit)
  A >>= 1

print(res % 1000000007)

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

r = []
for i in range(N - 1):
  for j in range(i+1, N):
    #r += (A[i]) ^ (A[j])
    r.append((A[i]) ^ (A[j]))

print(sum(r) % (10**9 + 7))

#print(bin(10**9 + 7))

Fixed submission:
import numpy as np 
N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

res = 0
for bit in range(60):
  c = int((A & 1).sum())
  res += c * (N - c) * (1 << bit)
  A >>= 1

print(res % 1000000007)

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

r = 0
for i in range(N - 1):
  for j in range(i+1, N):
    r += (A[i]) ^ (A[j])

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

Fixed submission:
import numpy as np 
N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

res = 0
for bit in range(60):
  c = int((A & 1).sum())
  res += c * (N - c) * (1 << bit)
  A >>= 1

print(res % 1000000007)