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):
  c=0
  for j in A:
    if j>>i&1:
      c+=1
  ans+=pow(2,i,mod)*c*(N-c)
  ans%=mod
print(ans)

Fixed submission:
def main():
  N=int(input())
  A=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(60):
    c=0
    for j in A:
      if j>>i&1:
        c+=1
    ans+=pow(2,i,mod)*c*(N-c)
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()

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):
  c=0
  for j in A:
    if j>>i&1==1:
      c+=1
  ans+=pow(2,i,mod)*c*(N-c)
  ans=ans%mod
print(ans)

Fixed submission:
def main():
  N=int(input())
  A=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(60):
    c=0
    for j in A:
      if j>>i&1:
        c+=1
    ans+=pow(2,i,mod)*c*(N-c)
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
dp=[0]*60
for i in range(60):
  for j in A:
    if j>>i&1==1:
      dp[i]+=1
      j+=1
ans=0
mod=10**9+7
for i in range(60):
  ans+=pow(2,i,mod)*dp[i]*(N-dp[i])
  ans%=mod
print(ans)

Fixed submission:
def main():
  N=int(input())
  A=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(60):
    c=0
    for j in A:
      if j>>i&1:
        c+=1
    ans+=pow(2,i,mod)*c*(N-c)
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
dp=[0]*61
for i in range(61):
  for j in A:
    if j>>i&1==1:
      dp[i]+=1
      j+=1
ans=0
mod=10**9+7
for i in range(61):
  ans+=pow(2,i,mod)*dp[i]*(N-dp[i])
  ans%=mod
print(ans)

Fixed submission:
def main():
  N=int(input())
  A=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(60):
    c=0
    for j in A:
      if j>>i&1:
        c+=1
    ans+=pow(2,i,mod)*c*(N-c)
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
dp=[0]*61
for i in range(N):
  a=len(bin(A[i]))-2
  for j in range(a):
    if A[i]&1==1:
      dp[j]+=1
    A[i]=A[i]>>1
ans=0
mod=10**9+7
for i in range(60,-1,-1):
  ans+=pow(2,i)*dp[i]*(N-dp[i])
  ans%=mod
print(ans)

Fixed submission:
def main():
  N=int(input())
  A=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(60):
    c=0
    for j in A:
      if j>>i&1:
        c+=1
    ans+=pow(2,i,mod)*c*(N-c)
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
dp=[0]*61
for i in range(N):
  a=len(bin(A[i]))-2
  for j in range(a):
    if A[i]>>j&1==1:
      dp[j]+=1
ans=0
mod=10**9+7
for i in range(60,-1,-1):
  
  ans+=pow(2,i)*dp[i]*(N-dp[i])
  ans%=mod
print(ans)

Fixed submission:
def main():
  N=int(input())
  A=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(60):
    c=0
    for j in A:
      if j>>i&1:
        c+=1
    ans+=pow(2,i,mod)*c*(N-c)
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()