Buggy python submission (verdict: Runtime Error):
def str2bitstr(chs):
    val = int(chs)
    tmp = bin(val)[2:]
    tmp2 = '0' * (59 - len(tmp))
    return tmp2 + tmp


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

cnts = [0] * 59

for item in a:
    for i, ch in enumerate(item):
        if ch == '1':
            cnts[i] += 1

ret = 0
now = 1

for i in range(1, 60):
    kumi = cnts[-i] * (n - cnts[-i]) % (10 ** 9 + 7)
    ret += kumi * now % (10 ** 9 + 7)
    now *= 2

print(ret % (10 ** 9 + 7))


Fixed submission:
def str2bitstr(chs):
    val = int(chs)
    tmp = bin(val)[2:]
    tmp2 = '0' * (60 - len(tmp))
    return tmp2 + tmp


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

cnts = [0] * 60

for item in a:
    for i, ch in enumerate(item):
        if ch == '1':
            cnts[i] += 1

ret = 0
now = 1

for i in range(1, 61):
    kumi = cnts[-i] * (n - cnts[-i]) % (10 ** 9 + 7)
    ret += kumi * now % (10 ** 9 + 7)
    now *= 2 % (10 ** 9 + 7)
    ret = ret % (10 ** 9 + 7)

print(ret % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
def modpow(a: int, p: int, mod: int) -> int:
    # return a**p (mod MOD) O(log p)
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod


n = int(input())
a_ls = list(map(int, input().split()))

ret = 0
cnt_1 = [0] * 60

for item in a_ls:
    for i in range(60):
        if len(bin(item)) <= i:
            continue
        elif bin(item)[-1-i] == '1':
            cnt_1[i] += 1

for i in range(60):
    tmp = ((n - cnt_1[i]) * cnt_1[i])
    tmp %= 10 ** 9 + 7
    tmp *= modpow(2, i, 10 ** 9 + 7)
    ret += tmp
    ret %= 10 ** 9 + 7

print(ret)


Fixed submission:
def str2bitstr(chs):
    val = int(chs)
    tmp = bin(val)[2:]
    tmp2 = '0' * (60 - len(tmp))
    return tmp2 + tmp


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

cnts = [0] * 60

for item in a:
    for i, ch in enumerate(item):
        if ch == '1':
            cnts[i] += 1

ret = 0
now = 1

for i in range(1, 61):
    kumi = cnts[-i] * (n - cnts[-i]) % (10 ** 9 + 7)
    ret += kumi * now % (10 ** 9 + 7)
    now *= 2 % (10 ** 9 + 7)
    ret = ret % (10 ** 9 + 7)

print(ret % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
def modpow(a: int, p: int, mod: int) -> int:
    # return a**p (mod MOD) O(log p)
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod


n = int(input())
a_ls = list(map(int, input().split()))

ret = 0
cnt_0 = [0] * 60
cnt_1 = [0] * 60

for item in a_ls:
    for i in range(60):
        if len(bin(item)) <= i:
            cnt_0[i] += 1
        elif bin(item)[-1-i] == '1':
            cnt_1[i] += 1
        else:
            cnt_0[i] += 1

for i in range(60):
    tmp = (cnt_0[i] * cnt_1[i])
    tmp %= 10 ** 9 + 7
    tmp *= modpow(2, i, 10 ** 9 + 7)
    ret += tmp
    ret %= 10 ** 9 + 7

print(ret)


Fixed submission:
def str2bitstr(chs):
    val = int(chs)
    tmp = bin(val)[2:]
    tmp2 = '0' * (60 - len(tmp))
    return tmp2 + tmp


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

cnts = [0] * 60

for item in a:
    for i, ch in enumerate(item):
        if ch == '1':
            cnts[i] += 1

ret = 0
now = 1

for i in range(1, 61):
    kumi = cnts[-i] * (n - cnts[-i]) % (10 ** 9 + 7)
    ret += kumi * now % (10 ** 9 + 7)
    now *= 2 % (10 ** 9 + 7)
    ret = ret % (10 ** 9 + 7)

print(ret % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_ls = list(map(int, input().split()))

ret = 0
cnt_0 = [0] * 60
cnt_1 = [0] * 60

for item in a_ls:
    for i in range(60):
        if len(bin(item)) <= i:
            cnt_0[i] += 1
        elif bin(item)[-1-i] == '1':
            cnt_1[i] += 1
        else:
            cnt_0[i] += 1

for i in range(60):
    tmp = (cnt_0[i] * cnt_1[i])
    for _ in range(i):
        tmp *= 2
        tmp %= 10 ** 9 + 7
    ret += tmp
    ret %= 10 ** 9 + 7

print(ret)


Fixed submission:
def str2bitstr(chs):
    val = int(chs)
    tmp = bin(val)[2:]
    tmp2 = '0' * (60 - len(tmp))
    return tmp2 + tmp


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

cnts = [0] * 60

for item in a:
    for i, ch in enumerate(item):
        if ch == '1':
            cnts[i] += 1

ret = 0
now = 1

for i in range(1, 61):
    kumi = cnts[-i] * (n - cnts[-i]) % (10 ** 9 + 7)
    ret += kumi * now % (10 ** 9 + 7)
    now *= 2 % (10 ** 9 + 7)
    ret = ret % (10 ** 9 + 7)

print(ret % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_ls = list(map(int, input().split()))

ret = 0
cnt_0 = [0] * 60
cnt_1 = [0] * 60

for item in a_ls:
    for i in range(60):
        if len(bin(item)) <= i:
            cnt_0[i] += 1
        elif bin(item)[-1-i] == '1':
            cnt_1[i] += 1
        else:
            cnt_0[i] += 1

for i in range(60):
    tmp = (cnt_0[i] * cnt_1[i])
    for _ in range(i):
        tmp *= 2
        tmp %= 10 ** 9 + 7
    ret += tmp
    ret %= 10 ** 9 + 7

print(ret)


Fixed submission:
def str2bitstr(chs):
    val = int(chs)
    tmp = bin(val)[2:]
    tmp2 = '0' * (60 - len(tmp))
    return tmp2 + tmp


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

cnts = [0] * 60

for item in a:
    for i, ch in enumerate(item):
        if ch == '1':
            cnts[i] += 1

ret = 0
now = 1

for i in range(1, 61):
    kumi = cnts[-i] * (n - cnts[-i]) % (10 ** 9 + 7)
    ret += kumi * now % (10 ** 9 + 7)
    now *= 2 % (10 ** 9 + 7)
    ret = ret % (10 ** 9 + 7)

print(ret % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_ls = list(map(int, input().split()))

ret = 0
cnt_0 = [0] * 60
cnt_1 = [0] * 60

for item in a_ls:
    for i in range(60):
        if len(bin(item)) <= i:
            cnt_0[i] += 1
        elif bin(item)[-1-i] == '1':
            cnt_1[i] += 1
        else:
            cnt_0[i] += 1

for i in range(60):
    ret += (cnt_0[i] * cnt_1[i]) * (2 ** i)
    ret %= 10 ** 9 + 7

print(ret)


Fixed submission:
def str2bitstr(chs):
    val = int(chs)
    tmp = bin(val)[2:]
    tmp2 = '0' * (60 - len(tmp))
    return tmp2 + tmp


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

cnts = [0] * 60

for item in a:
    for i, ch in enumerate(item):
        if ch == '1':
            cnts[i] += 1

ret = 0
now = 1

for i in range(1, 61):
    kumi = cnts[-i] * (n - cnts[-i]) % (10 ** 9 + 7)
    ret += kumi * now % (10 ** 9 + 7)
    now *= 2 % (10 ** 9 + 7)
    ret = ret % (10 ** 9 + 7)

print(ret % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_ls = list(map(int, input().split()))

ret = 0

for i in range(60):
    cnt_0 = 0
    cnt_1 = 0
    for item in a_ls:
        if len(bin(item)) <= i:
            cnt_0 += 1
        elif bin(item)[-1-i] == '1':
            cnt_1 += 1
        else:
            cnt_0 += 1
    ret += cnt_1 * cnt_0 * (2 ** i)
    ret %= 10 ** 9 + 7

print(ret)


Fixed submission:
def str2bitstr(chs):
    val = int(chs)
    tmp = bin(val)[2:]
    tmp2 = '0' * (60 - len(tmp))
    return tmp2 + tmp


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

cnts = [0] * 60

for item in a:
    for i, ch in enumerate(item):
        if ch == '1':
            cnts[i] += 1

ret = 0
now = 1

for i in range(1, 61):
    kumi = cnts[-i] * (n - cnts[-i]) % (10 ** 9 + 7)
    ret += kumi * now % (10 ** 9 + 7)
    now *= 2 % (10 ** 9 + 7)
    ret = ret % (10 ** 9 + 7)

print(ret % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_ls = list(map(int, input().split()))

ret = 0

for i in range(60):
    cnt_0 = 0
    cnt_1 = 0
    for item in a_ls:
        if len(bin(item)) <= i:
            cnt_0 += 1
        elif bin(item)[-1-i] == '1':
            cnt_1 += 1
        else:
            cnt_0 += 1
    ret += cnt_1 * cnt_0 * (2 ** i)
    ret %= 10 ** 9 + 7

print(ret)


Fixed submission:
def str2bitstr(chs):
    val = int(chs)
    tmp = bin(val)[2:]
    tmp2 = '0' * (60 - len(tmp))
    return tmp2 + tmp


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

cnts = [0] * 60

for item in a:
    for i, ch in enumerate(item):
        if ch == '1':
            cnts[i] += 1

ret = 0
now = 1

for i in range(1, 61):
    kumi = cnts[-i] * (n - cnts[-i]) % (10 ** 9 + 7)
    ret += kumi * now % (10 ** 9 + 7)
    now *= 2 % (10 ** 9 + 7)
    ret = ret % (10 ** 9 + 7)

print(ret % (10 ** 9 + 7))