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


Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
L=len(format(max(a),"b"))
s=[0]*L
for i in range(n):
  c=format(a[i], 'b').zfill(L)
  for j in range(L)[::-1]:
    s[j]+=int(c[j])
ans=0
for i in range(len(s))[::-1]:
  ans+=2**(i)*(s[L-i-1])*(n-s[L-i-1])
  ans%=mod
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
L=len(format(max(a),"b"))
s=[0]*L
for i in range(n):
  c=format(a[i], 'b').zfill(L)
  for j in range(L)[::-1]:
    s[j]+=int(c[j])
ans=0
for i in range(len(s))[::-1]:
  ans+=2**(i)*(s[L-i-1])*(n-s[L-i-1])
  ans%=mod
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
L=len(format(max(a),"b"))
s=[0]*L
for i in range(n):
  c=format(a[i], 'b').zfill(L)
  for j in range(L)[::-1]:
    s[j]+=int(c[j])
ans=0
for i in range(len(s))[::-1]:
  ans+=2**(i)*(s[L-i-1])*(n-s[L-i-1])
  ans%=mod
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
L=len(format(max(a),"b"))
s=[0]*L
for i in range(n):
  c=format(a[i], 'b').zfill(L)
  for j in range(len(c))[::-1]:
    s[j]+=int(c[j])
ans=0
for i in range(len(s))[::-1]:
  add=(s[L-i-1])*(n-s[L-i-1])
  for j in range(i):
    add*=2
    add%=mod
  ans+=add
  ans%=mod
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
L=len(format(max(a),"b"))
s=[0]*L
for i in range(n):
  c=format(a[i], 'b').zfill(L)
  for j in range(L)[::-1]:
    s[j]+=int(c[j])
ans=0
for i in range(len(s))[::-1]:
  ans+=2**(i)*(s[L-i-1])*(n-s[L-i-1])
  ans%=mod
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
L=len(format(max(a),"b"))
s=[0]*L
for i in range(n):
  c=format(a[i], 'b').zfill(L)
  for j in range(len(c))[::-1]:
    s[j]+=int(c[j])
ans=0
for i in range(len(s))[::-1]:
  ans+=2**(i)*(s[L-i-1])*(n-s[L-i-1])
  ans%=mod
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
L=len(format(max(a),"b"))
s=[0]*L
for i in range(n):
  c=format(a[i], 'b').zfill(L)
  for j in range(len(c))[::-1]:
    s[j]+=int(c[j])
ans=0
for i in range(len(s))[::-1]:
  ans+=2**(i)*(s[L-i-1])*(n-s[L-i-1])
  ans%=mod
print(ans)

Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)