Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N = ir()
A = np.array(lr(), np.int64)
answer = 0
limit = A.max().bit_length()
for i in range(limit):
    B = (A >> i) & 1
    x = np.count_nonzero(B)
    y = N - x
    add = (x*y) * 2 ** i % MOD
    answer += add

print(answer%MOD)


Fixed submission:
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = np.array(rl())
answer = 0
MOD = 10 ** 9 + 7

for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x

print(answer%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N = ir()
A = lr()
bit = [0 for _ in range(60)]
for a in A:
    for i in range(a.bit_length()):
        if (a >> i) & 1:
            bit[i] += 1

answer = 0
for i, x in enumerate(bit):
    answer += x * (N-x) * 2 ** i % MOD

print(answer%MOD)
# 22

Fixed submission:
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = np.array(rl())
answer = 0
MOD = 10 ** 9 + 7

for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x

print(answer%MOD)

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

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = rl()
MOD = 10 ** 9 + 7
#1番目以降(N個の数)のbitの格桁の合計
l = np.array([0] * 60)
for i in range(N):
    s = np.array(list(map(int, list(str(bin(A[i]))[2:].rjust(60, '0')))))
    #print(s)
    l = l + s
l2 = np.array([0] * 60)
#print(l)
for i in range(N-1):
    s = np.array(list(map(int, list(str(bin(A[i]))[2:].rjust(60, '0')))))
    x = N - 1 - i
    l -= s
    l2 += s * (x-l)
    l2 += (1-s) * l
    
answer = 0
#print(l2)
l2 = l2.tolist()
for i in range(60):
    answer += 2 ** (59-i) * l2[i]
    answer %= MOD
#print(l)
print(answer)



Fixed submission:
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = np.array(rl())
answer = 0
MOD = 10 ** 9 + 7

for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x

print(answer%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = rl()
MOD = 10 ** 9 + 7
#1番目以降(N個の数)のbitの格桁の合計
l = [0] * 60
for i in range(N):
    s = list(str(bin(A[i]))[2:].rjust(60, '0'))
    #print(s)
    for j in range(60):
        if s[j] == '1':
            l[j] += 1
l2 = [0] * 60
#print(l)
for i in range(N-1):
    s = list(str(bin(A[i]))[2:].rjust(60, '0'))
    x = N - 1 - i
    for j in range(60):
        if s[j] == '1':
            l[j] -= 1
            l2[j] += x - l[j]
        else:
            l2[j] += l[j]
answer = 0
#print(l2)
for i in range(60):
    answer += 2 ** (59-i) * l2[i]
    answer %= MOD
#print(l)
print(answer)



Fixed submission:
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = np.array(rl())
answer = 0
MOD = 10 ** 9 + 7

for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x

print(answer%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = rl()
MOD = 10 ** 9 + 7
#1番目以降(N個の数)のbitの格桁の合計
l = [0] * 60
for i in range(N):
    s = list(str(bin(A[i]))[2:].rjust(60, '0'))
    #print(s)
    for j in range(60):
        if s[j] == '1':
            l[j] += 1
l2 = [0] * 60
#print(l)
for i in range(N-1):
    s = list(str(bin(A[i]))[2:].rjust(60, '0'))
    for j in range(60):
        if s[j] == '1':
            l[j] -= 1
            l2[j] += N - 1 - i - l[j]
        else:
            l2[j] += l[j]
answer = 0
#print(l2)
for i in range(60):
    answer += 2 ** (59-i) * l2[i]
    answer %= MOD
#print(l)
print(answer)



Fixed submission:
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = np.array(rl())
answer = 0
MOD = 10 ** 9 + 7

for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x

print(answer%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = rl()
MOD = 10 ** 9 + 7
#1番目以降(N個の数)のbitの格桁の合計
l = [0] * 60
for i in range(N):
    s = list(str(bin(A[i]))[2:].rjust(60, '0'))
    #print(s)
    for j in range(60):
        if s[j] == '1':
            l[j] += 1
l2 = [0] * 60
#print(l)
for i in range(N-1):
    s = list(str(bin(A[i]))[2:].rjust(60, '0'))
    for j in range(60):
        if s[j] == '1':
            l[j] -= 1
            l2[j] += N - 1 - i - l[j]
        else:
            l2[j] += l[j]
answer = 0
#print(l2)
for i in range(60):
    answer += 2 ** (59-i) * l2[i]
    answer %= MOD
#print(l)
print(answer)



Fixed submission:
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = np.array(rl())
answer = 0
MOD = 10 ** 9 + 7

for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x

print(answer%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = rl()
MOD = 10 ** 9 + 7
#2番目以降(N-1個の数)のbitの格桁の合計
l = [0] * 60
for i in range(N):
    s = list(str(bin(A[i]))[2:].rjust(60, '0'))
    #print(s)
    for j in range(60):
        if s[j] == '1':
            l[j] += 1
answer = 0
#print(l)
for i in range(N-1):
    s = list(str(bin(A[i]))[2:].rjust(60, '0'))
    for j in range(60):
        if s[j] == '1':
            l[j] -= 1
            answer += 2 ** (59-j) * (N - 1 - i - l[j])
        else:
            answer += 2 ** (59-j) * l[j]
    answer %= MOD
#print(l)
print(answer)



Fixed submission:
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = np.array(rl())
answer = 0
MOD = 10 ** 9 + 7

for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x

print(answer%MOD)