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

ans = 0
for i in range(60):
  num_one = len([1 for x in A if x & (1 << i)])
  ans = ans + (1 << i) * num_one * (N - num_one)
print(ans % 1000000007)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)

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

ans = 0
for i in range(60):
  num_one = len([1 for x in A if x & (1 << i)])
  ans = (ans + (1 << i) * num_one * (N - num_one)) % 1000000007
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
def d():
  N = int(input())
  A = list(map(int,input().split()))
  
  ans = 0
  for i in range(60):
    num_one = sum([1 for x in range(N) if A[x] & (1 << i) != 0])
    ans = (ans + (1 << i) * num_one * (N - num_one)) % 1000000007
  print(ans)
        
d()


Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)

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

  num_ones = [0]*60
  powers_of_two = [1]
  for i in range(1,60):
    powers_of_two.append((powers_of_two[-1] << 1) % 1000000007)
  
  ans = 0
  for i in range(N-1,-1,-1):
    for j in range(60):
      if A[i] & 1 == 0:
        ans = (ans + powers_of_two[j] * num_ones[j]) % 1000000007
      else:
        ans = (ans + powers_of_two[j] * (N - i - 1 - num_ones[j])) % 1000000007
        num_ones[j] += 1
      A[i] >>= 1
  print(ans)
        
d()


Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)

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

num_ones = [0]*60
powers_of_two = [pow(2,x,1000000007) for x in range(60)]

ans = 0
for i in range(N-1,-1,-1):
  for j in range(60):
    if A[i] & 1:
      ans = (ans + powers_of_two[j] * (N - i - 1 - num_ones[j])) % 1000000007
      num_ones[j] += 1
    else:
      ans = (ans + powers_of_two[j] * num_ones[j]) % 1000000007
    A[i] >>= 1
print(ans)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)

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

  num_ones = [0 for x in range(60)]
  powers_of_two = [1]
  for i in range(1,60):
    powers_of_two.append((powers_of_two[-1] * 2) % 1000000007)
  
  ans = 0
  for i in range(N-1,-1,-1):
    for j in range(60):
      if A[i] & 1 == 0:
        ans = (ans + powers_of_two[j] * num_ones[j]) % 1000000007
      else:
        ans = (ans + powers_of_two[j] * (N - i - 1 - num_ones[j])) % 1000000007
        num_ones[j] += 1
      A[i] >>= 1
  print(ans)
        
d()


Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)

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

  num_ones = [0 for x in range(60)]
  for i in range(N):
    k = A[i]
    cnt = 0
    while k:
      num_ones[cnt] += k % 2
      cnt += 1
      k >>= 1

  powers_of_two = [1]
  for i in range(1,60):
    powers_of_two.append((powers_of_two[-1] * 2) % 1000000007)
  
  ans = 0
  for i in range(N-1):
    for j in range(60):
      if A[i] & 1 == 0:
        ans = (ans + powers_of_two[j] * num_ones[j]) % 1000000007
      else:
        num_ones[j] -= 1
        ans = (ans + powers_of_two[j] * (N - i - 1 - num_ones[j])) % 1000000007
      A[i] >>= 1
  print(ans)
        
d()

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)

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

  num_ones = [0 for x in range(60)]
  for i in range(N):
    k = A[i]
    cnt = 0
    while k:
      num_ones[cnt] += k % 2
      cnt += 1
      k //= 2

  powers_of_two = [1]
  for i in range(1,60):
    powers_of_two.append((powers_of_two[-1] * 2) % 1000000007)
  
  ans = 0
  for i in range(N-1):
    for j in range(60):
      if A[i] % 2 == 0:
        ans = (ans + powers_of_two[j] * num_ones[j]) % 1000000007
      else:
        num_ones[j] -= 1
        ans = (ans + powers_of_two[j] * (N - i - 1 - num_ones[j])) % 1000000007
      A[i] //= 2
  print(ans)
        
d()

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)

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

  num_ones = [0 for x in range(60)]
  for i in range(N):
    k = A[i]
    cnt = 0
    while k:
      num_ones[cnt] += k % 2
      cnt += 1
      k //= 2
  
  ans = 0
  for i in range(N-1):
    for j in range(60):
      if A[i] % 2 == 0:
        ans = (ans + (1 << j) * num_ones[j]) % 1000000007
      else:
        num_ones[j] -= 1
        ans = (ans + (1 << j) * (N - i - 1 - num_ones[j])) % 1000000007
      A[i] //= 2
  print(ans)
        
d()

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
def d():
  from math import log2

  def get_ones(n):
    while n:
      k = n & -n
      yield int(log2(k))
      n ^= k

  N = int(input())
  A = list(map(int,input().split()))

  num_ones = [0 for x in range(60)]
  for i in range(N):
    for j in get_ones(A[i]):
      num_ones[j] += 1
  
  ans = 0
  for i in range(N-1):
    for j in range(60):
      if A[i] % 2 == 0:
        ans = (ans + (1 << j) * num_ones[j]) % 1000000007
      else:
        num_ones[j] -= 1
        ans = (ans + (1 << j) * (N - i - 1 - num_ones[j])) % 1000000007
      A[i] //= 2
  print(ans)
        
d()

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)