Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
for k in range(60):
  t=1<<k
  z=o=0
  for i in a:
    if i&t:o+=1
    else:z+=1
  ans=(ans+(z*o*t))%mod
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
x=1
for i in range(60):
  z=o=0
  for j in range(n):
    if a[j]%2:o+=1
    else:z+=1
    a[j]//=2
  ans+=(x*o*z)%mod
  ans%=mod
  x=(x*2)%mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
for i in range(60):
  o=0
  x=1<<i
  for j in a:
    if j&x:o+=1
  ans+=x*o*(n-o)
  ans%=mod
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
x=1
for i in range(60):
  z=o=0
  for j in range(n):
    if a[j]%2:o+=1
    else:z+=1
    a[j]//=2
  ans+=(x*o*z)%mod
  ans%=mod
  x=(x*2)%mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
o=[0]*61
z=[0]*61
mod=10**9+7
ans=0
for i in range(n):
  x=a[i]
  for j in range(61):
    if x&1:o[j]+=1
    else:z[j]+=1
    x>>=1
x=1
for i in range(61):
  ans=(ans+(x*o[i]*z[i])%mod)%mod
  x=(x*2%mod)
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
x=1
for i in range(60):
  z=o=0
  for j in range(n):
    if a[j]%2:o+=1
    else:z+=1
    a[j]//=2
  ans+=(x*o*z)%mod
  ans%=mod
  x=(x*2)%mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
for i in range(60):
  x=1<<i
  z=o=0
  for j in range(n):
    if a[j]&x:o+=1
    else:z+=1
  ans=(ans+((x%mod)*o*z)%mod)%mod
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
x=1
for i in range(60):
  z=o=0
  for j in range(n):
    if a[j]%2:o+=1
    else:z+=1
    a[j]//=2
  ans+=(x*o*z)%mod
  ans%=mod
  x=(x*2)%mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
x=1
for i in range(60):
  z=o=0
  for j in range(n):
    if a[j]%2:o+=1
    else:z+=1
    a[j]//=2
  ans+=(x*o*z)%mod
  ans%=mod
  x=(x*2)%mod
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
x=1
for i in range(60):
  z=o=0
  for j in range(n):
    if a[j]%2:o+=1
    else:z+=1
    a[j]//=2
  ans+=(x*o*z)%mod
  ans%=mod
  x=(x*2)%mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[61*[0]for _ in range(n)]
c=[0]*61
for i in range(n):
  s=bin(a[i])[2:].zfill(61)
  for j in range(61):
    if s[-j-1]=="1":
      c[j]+=1
      b[i][j]=1
ans=0
mod=10**9+7
mod*=2
for i in range(n):
  x=1
  for j in range(61):
    if b[i][j]==1:s=n-c[j]
    else:s=c[j]
    ans+=s*x
    x=(x*2)%mod
    ans%=mod
print(ans//2)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
x=1
for i in range(60):
  z=o=0
  for j in range(n):
    if a[j]%2:o+=1
    else:z+=1
    a[j]//=2
  ans+=(x*o*z)%mod
  ans%=mod
  x=(x*2)%mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[61*[0]for _ in range(n)]
c=[0]*61
for i in range(n):
  s=bin(a[i])[2:].zfill(61)
  for j in range(61):
    if s[-j-1]=="1":
      c[j]+=1
      b[i][j]=1
ans=0
mod=10**9+7
mod*=2
for i in range(n):
  x=1
  for j in range(61):
    if b[i][j]==1:s=n-c[j]
    else:s=c[j]
    ans+=s*x
    x=(x*2)%mod
    ans%=mod
print(ans//2)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
x=1
for i in range(60):
  z=o=0
  for j in range(n):
    if a[j]%2:o+=1
    else:z+=1
    a[j]//=2
  ans+=(x*o*z)%mod
  ans%=mod
  x=(x*2)%mod
print(ans)