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

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
p = [pow(2, i, mod) for i in range(60)]
ans = 0
for i in range(60):
    c = 0
    for j in a:
        if (j >> i) & 1:
            c += 1
    ans += (c * (n - c) * p[i]) % 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
p = [pow(2, i, mod) for i in range(60)]
l0 = [n] * 60
l1 = [0] * 60
for i in a:
    t = list(format(i, "b"))
    for j in range(len(t)):
        if int(t[j]) == 1:
            l0[len(t) - 1 - j] -= 1
            l1[len(t) - 1 - j] += 1
ans = 0
for i in range(60):
    ans += (l0[i] * l1[i] * p[i]) % mod
    ans %= mod
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
p = [pow(2, i, mod) for i in range(60)]
ans = 0
for i in range(60):
    c = 0
    for j in a:
        if (j >> i) & 1:
            c += 1
    ans += (c * (n - c) * p[i]) % 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
p = [pow(2, i, mod) for i in range(60)]
l0 = [0] * 60
l1 = [0] * 60
for i in a:
    t = list(format(i, "b"))
    for j in range(len(t)):
        if int(t[j]) == 0:
            l0[len(t) - 1 - j] += 1
        else:
            l1[len(t) - 1 - j] += 1
    for j in range(len(t), 60):
        l0[j] += 1
ans = 0
for i in range(60):
    ans += (l0[i] * l1[i] * p[i]) % mod
    ans %= mod
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
p = [pow(2, i, mod) for i in range(60)]
ans = 0
for i in range(60):
    c = 0
    for j in a:
        if (j >> i) & 1:
            c += 1
    ans += (c * (n - c) * p[i]) % 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
p = [pow(2, i, mod) for i in range(60)]
l0 = [0] * 60
l1 = [0] * 60
for i in a:
    t = list(format(i, "b"))
    for j in range(len(t)):
        if int(t[j]) == 0:
            l0[len(t) - 1 - j] += 1
        else:
            l1[len(t) - 1 - j] += 1
    for j in range(len(t), 60):
        l0[j] += 1
ans = 0
for i in range(60):
    ans += (l0[i] * l1[i] * p[i]) % mod
    ans %= mod
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
p = [pow(2, i, mod) for i in range(60)]
ans = 0
for i in range(60):
    c = 0
    for j in a:
        if (j >> i) & 1:
            c += 1
    ans += (c * (n - c) * p[i]) % mod
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
B = list()
ans = 0
for i in range(n - 1):
    for j in range(n - i - 1):
        b = A[i] ^ A[j + i + 1]
        if ans + b < 1000000007:
            ans += b
        else:
            ans = (ans + b) % 1000000007
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
p = [pow(2, i, mod) for i in range(60)]
ans = 0
for i in range(60):
    c = 0
    for j in a:
        if (j >> i) & 1:
            c += 1
    ans += (c * (n - c) * p[i]) % mod
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
B = list()
ans = 0
for i in range(n - 1):
    for j in range(n - i - 1):
        b = A[i] ^ A[j + i + 1]
        B.append(b)
        len_B = len(B)
        if ans + B[len_B - 1] < 1000000007:
            ans += b
        else:
            ans = (ans + b) % 1000000007
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
p = [pow(2, i, mod) for i in range(60)]
ans = 0
for i in range(60):
    c = 0
    for j in a:
        if (j >> i) & 1:
            c += 1
    ans += (c * (n - c) * p[i]) % mod
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
B = list()
ans = 0
for i in range(n - 1):
    for j in range(n - i - 1):
        b = A[i] ^ A[j + i + 1]
        B.append(b)
for i in range(len(B)):
    if ans + B[i] < 1000000007:
        ans += B[i]
    else:
        ans = (ans + B[i]) % 1000000007
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
p = [pow(2, i, mod) for i in range(60)]
ans = 0
for i in range(60):
    c = 0
    for j in a:
        if (j >> i) & 1:
            c += 1
    ans += (c * (n - c) * p[i]) % mod
    ans %= mod
print(ans)