Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))
bite = [0 for _ in range(60)]
for A in A_list:
    for i in range(60):
        if A & 1 << i:
            bite[i] += 1

ans = 0
on_right = N - 1
for num in range(len(A_list)):
    A = A_list[num]
    for i in range(60):
        if A & 1 << i:
            bite[i] -= 1
            ans += (on_right - bite[i]) * 1 << i
        else:
            ans += bite[i] * 1 << i
    on_right -= 1

ans %= (10 ** 9 + 7)
print(ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
one = [0 for _ in range(60)]

for a in A:
    for i in range(60):
        if a & 1 << i:
            one[i] += 1
ans = 0
for a in A:
    n -= 1
    if n == 0:
        break
    for i in range(60):
        if a & 1 << i:
            one[i] -= 1

    for i in range(60):
        if a & 1 << i:
            ans += (1 << i) * (n - one[i])
        else:
            ans += (1 << i) * one[i]

print(ans % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))
bite = [0 for _ in range(60)]
for A in A_list:
    for i in range(60):
        if A & 1 << i:
            bite[i] += 1

ans = 0
on_right = N - 1
for num in range(len(A_list)):
    A = A_list[num]
    for i in range(60):
        if A & 1 << i:
            bite[i] -= 1
            ans += (on_right - bite[i]) * 1 << i
        else:
            ans += bite[i] * 1 << i
    on_right -= 1

ans %= (10 ** 9 + 7)
print(ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
one = [0 for _ in range(60)]

for a in A:
    for i in range(60):
        if a & 1 << i:
            one[i] += 1
ans = 0
for a in A:
    n -= 1
    if n == 0:
        break
    for i in range(60):
        if a & 1 << i:
            one[i] -= 1

    for i in range(60):
        if a & 1 << i:
            ans += (1 << i) * (n - one[i])
        else:
            ans += (1 << i) * one[i]

print(ans % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
one = [0 for _ in range(60)]

for a in A:
    for i in range(60):
        if a & 1 << i:
            one[i] += 1
ans = 0
for j, a in enumerate(A):
    n -= 1
    if n == 0:
        break
    for i in range(60):
        if a & 1 << i:
            one[i] -= 1
    # print(one)

    for i in range(60):
        if a & 1 << i:
            ans += (1 << i) * (n - one[i])
        else:
            ans += (1 << i) * one[i]


print(ans % 1000000007)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
one = [0 for _ in range(60)]

for a in A:
    for i in range(60):
        if a & 1 << i:
            one[i] += 1
ans = 0
for a in A:
    n -= 1
    if n == 0:
        break
    for i in range(60):
        if a & 1 << i:
            one[i] -= 1

    for i in range(60):
        if a & 1 << i:
            ans += (1 << i) * (n - one[i])
        else:
            ans += (1 << i) * one[i]

print(ans % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
one = [0 for _ in range(60)]

for a in A:
    for i in range(60):
        if a & 1 << i:
            one[i] += 1
ans = 0
for j, a in enumerate(A):
    n -= 1
    if n == 0:
        break
    for i in range(60):
        if a & 1 << i:
            one[i] -= 1
    # print(one)

    for i in range(60):
        if a & 1 << i:
            ans += (1 << i) * (n - one[i])
        else:
            ans += (1 << i) * one[i]


print(ans % 1000000007)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
one = [0 for _ in range(60)]

for a in A:
    for i in range(60):
        if a & 1 << i:
            one[i] += 1
ans = 0
for a in A:
    n -= 1
    if n == 0:
        break
    for i in range(60):
        if a & 1 << i:
            one[i] -= 1

    for i in range(60):
        if a & 1 << i:
            ans += (1 << i) * (n - one[i])
        else:
            ans += (1 << i) * one[i]

print(ans % 1000000007)