Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a = list(map(lambda x: (str(bin(x))[2:]).zfill(60), a))
mod = 10**9 + 7
ans = 0
for i in range(60):
    cnt = 0
    for j in a:
        cnt += int(j[-1*(i+1)])
    ans += cnt * (n-cnt) * pow(2, i, mod) % mod
    ans %= mod
print(ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = list(map(lambda x: (str(bin(x))[2:]).zfill(65), a))
mod = 10**9 + 7
ans = 0
for i in range(65):
    cnt = 0
    for j in a:
        if j[-1*(i+1)] == "1": cnt += 1
    ans += cnt * (n-cnt) * pow(2, i, mod) % mod
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a = list(map(lambda x: (str(bin(x))[2:]).zfill(65), a))
mod = 10**9 + 7
ans = 0
for i in range(65):
    cnt = 0
    for j in a:
        if j[-1*(i+1)] == "1": cnt += 1
    ans += cnt * (n-cnt) * pow(2, i, mod) % mod
    ans %= mod
print(ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = list(map(lambda x: (str(bin(x))[2:]).zfill(65), a))
mod = 10**9 + 7
ans = 0
for i in range(65):
    cnt = 0
    for j in a:
        if j[-1*(i+1)] == "1": cnt += 1
    ans += cnt * (n-cnt) * pow(2, i, mod) % mod
    ans %= 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
keta = 0
while a != [0]*n:
    b = list(map(lambda x: x % 2, a))
    a = list(map(lambda x: x//2, a))
    num_1 = b.count(1)
    ans += (num_1 * (n-num_1) * pow(2, keta, mod)) % mod
    ans %= mod
    keta += 1
print(ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = list(map(lambda x: (str(bin(x))[2:]).zfill(65), a))
mod = 10**9 + 7
ans = 0
for i in range(65):
    cnt = 0
    for j in a:
        if j[-1*(i+1)] == "1": cnt += 1
    ans += cnt * (n-cnt) * pow(2, i, mod) % mod
    ans %= 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
keta = 0
while a != [0]*n:
    b = list(map(lambda x: x % 2, a))
    a = list(map(lambda x: x//2, a))
    num_1 = b.count(1)
    ans += (num_1 * (n-num_1) * pow(2, keta, mod)) % mod
    ans %= mod
    keta += 1
print(ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = list(map(lambda x: (str(bin(x))[2:]).zfill(65), a))
mod = 10**9 + 7
ans = 0
for i in range(65):
    cnt = 0
    for j in a:
        if j[-1*(i+1)] == "1": cnt += 1
    ans += cnt * (n-cnt) * pow(2, i, mod) % mod
    ans %= 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
keta = 0
while a != [0]*n:
    b = list(map(lambda x: x % 2, a))
    a = list(map(lambda x: x//2, a))
    ans += b.count(0) * b.count(1) * 2**keta
    ans %= mod
    keta += 1
print(ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = list(map(lambda x: (str(bin(x))[2:]).zfill(65), a))
mod = 10**9 + 7
ans = 0
for i in range(65):
    cnt = 0
    for j in a:
        if j[-1*(i+1)] == "1": cnt += 1
    ans += cnt * (n-cnt) * pow(2, i, mod) % mod
    ans %= mod
print(ans)