Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
MOD = 10**9 + 7
def solve(n, a, p=60):
    b = [np.asarray(list(bin(x)[2:].zfill(p)), dtype=int) for x in a]
    b = np.asarray(b, dtype=int)
    s = np.sum(b, axis=0)
    res = sum(int(s[i]) * int(n - s[i]) * (2**(p-1-i)) for i in range(p))
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Fixed submission:
MOD = 10**9 + 7
def solve(n, a, p=60):
    res, m = 0, 1
    for i in range(p):
        y = sum(x & m for x in a) // m
        res += y * (n-y) * m
        m *= 2
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

MOD = 10**9 + 7
def solve(n, a, p=60):
    s = np.zeros(p, dtype=int)
    t = np.zeros(p, dtype=int)
    a = a[::-1]
    for i in range(n):
        mask = bin(a[i])[2:].zfill(p)
        mask = np.asarray(list(mask), dtype=int)
        s += mask
        t += mask * (i+1-s) + (1-mask) * s
    res = 0
    for j in range(p):
        res += int(t[j]) * (2**(p-1-j))
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Fixed submission:
MOD = 10**9 + 7
def solve(n, a, p=60):
    res, m = 0, 1
    for i in range(p):
        y = sum(x & m for x in a) // m
        res += y * (n-y) * m
        m *= 2
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

MOD = 10**9 + 7
def solve(n, a, p=60):
    s = np.zeros(p, dtype=int)
    t = np.zeros(p, dtype=int)
    a = a[::-1]
    for i in range(n):
        mask = bin(a[i])[2:].zfill(p)[::-1]
        mask = np.asarray(list(mask), dtype=int)
        s += mask
        t += mask * (i+1-s) + (1-mask) * s
    res = 0
    for j in range(p):
        res += int(t[j]) * (2**j)
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Fixed submission:
MOD = 10**9 + 7
def solve(n, a, p=60):
    res, m = 0, 1
    for i in range(p):
        y = sum(x & m for x in a) // m
        res += y * (n-y) * m
        m *= 2
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

MOD = 10**9 + 7
def solve(n, a, p=60):
    s = np.zeros(p, dtype=int)
    t = np.zeros(p, dtype=int)
    a = a[::-1]
    for i in range(n):
        mask = bin(a[i])[2:].zfill(p)[::-1]
        mask = np.asarray(list(map(int, mask)), dtype=int)
        s += mask
        t += mask * (i+1-s) + (1-mask) * s
    res = 0
    for j in range(p):
        res += int(t[j]) * (2**j)
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Fixed submission:
MOD = 10**9 + 7
def solve(n, a, p=60):
    res, m = 0, 1
    for i in range(p):
        y = sum(x & m for x in a) // m
        res += y * (n-y) * m
        m *= 2
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

MOD = 10**9 + 7
def solve(n, a, p=64):
    s = np.zeros(p, dtype=int)
    t = np.zeros(p, dtype=int)
    a = a[::-1]
    for i in range(n):
        mask = bin(a[i])[2:].zfill(p)[::-1]
        mask = np.asarray(list(map(int, mask)), dtype=int)
        s += mask
        for j in range(p):
            if mask[j] == 1:
                t[j] += i - s[j] + 1
            else:
                t[j] += s[j]
    res = 0
    for j in range(p):
        res += int(t[j]) * (2**j)
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Fixed submission:
MOD = 10**9 + 7
def solve(n, a, p=60):
    res, m = 0, 1
    for i in range(p):
        y = sum(x & m for x in a) // m
        res += y * (n-y) * m
        m *= 2
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

MOD = 10**9 + 7
def solve(n, a, p=64):
    s = np.zeros(p, dtype=int)
    a = a[::-1]
    res = 0
    for i in range(n):
        mask = bin(a[i])[2:].zfill(p)[::-1]
        mask = np.asarray(list(map(int, mask)), dtype=int)
        s += mask
        for j in range(p):
            if mask[j] == 1:
                res += (i - int(s[j]) + 1) * (2**j)
            else:
                res += int(s[j]) * (2**j)
        res %= MOD
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Fixed submission:
MOD = 10**9 + 7
def solve(n, a, p=60):
    res, m = 0, 1
    for i in range(p):
        y = sum(x & m for x in a) // m
        res += y * (n-y) * m
        m *= 2
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9 + 7
def solve(n, a, p=64):
    s = [0] * p
    a = a[::-1]
    res = 0
    for i in range(n):
        mask = bin(a[i])[2:][::-1]
        c = [0] * p
        for j, b in enumerate(map(int, mask)):
            s[j] += b
            c[j] = b
        for j in range(p):
            if c[j] == 1:
                res += (i - s[j] + 1) * (2**j)
            else:
                res += s[j] * (2**j)
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))


Fixed submission:
MOD = 10**9 + 7
def solve(n, a, p=60):
    res, m = 0, 1
    for i in range(p):
        y = sum(x & m for x in a) // m
        res += y * (n-y) * m
        m *= 2
    return res % MOD

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))