Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60)[::-1] for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a):
        memo_ls[i][j] = memo_ls[i-1][j] + int(k)

res = 0
for i in range(60):
    res += memo_ls[-1][i] * (n - memo_ls[-1][i]) * 2 ** i
    res %= MOD
print(res)

Fixed submission:
import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60)[::-1] for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
ct = {i : 0 for i in range(60)}
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a):
        if k == "1":
            ct[j] += 1

res = 0
for i in range(60):
    res += ct[i] * (n - ct[i]) * 2 ** i
    res %= MOD
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60) for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a[::-1]):
        memo_ls[i][j] = memo_ls[i-1][j] + int(k)

res = 0
for i in range(60):
    res += memo_ls[-1][i] * (n - memo_ls[-1][i]) * 2 ** i
    res %= MOD
print(res)

Fixed submission:
import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60)[::-1] for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
ct = {i : 0 for i in range(60)}
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a):
        if k == "1":
            ct[j] += 1

res = 0
for i in range(60):
    res += ct[i] * (n - ct[i]) * 2 ** i
    res %= MOD
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60) for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a[::-1]):
        memo_ls[i][j] = memo_ls[i-1][j] + int(k)

res = 0
for i, a in enumerate(a_ls):
    for j, x in enumerate(a[::-1]):
        if x == "0":
            res += 2 ** j * memo_ls[n-1-i][j]
        else:
            res += 2 ** j * (n - 1 - i - memo_ls[n-1-i][j])
        res %= MOD
print(res)

Fixed submission:
import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60)[::-1] for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
ct = {i : 0 for i in range(60)}
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a):
        if k == "1":
            ct[j] += 1

res = 0
for i in range(60):
    res += ct[i] * (n - ct[i]) * 2 ** i
    res %= MOD
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60) for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a[::-1]):
        memo_ls[i][j] = memo_ls[i-1][j] + int(k)

res = 0
for i, a in enumerate(a_ls):
    for j, x in enumerate(a[::-1]):
        if x == "0":
            res += 2 ** j * memo_ls[n-1-i][j]
        else:
            res += 2 ** j * (n - 1 - i - memo_ls[n-1-i][j])
        res %= MOD
print(res)

Fixed submission:
import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60)[::-1] for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
ct = {i : 0 for i in range(60)}
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a):
        if k == "1":
            ct[j] += 1

res = 0
for i in range(60):
    res += ct[i] * (n - ct[i]) * 2 ** i
    res %= MOD
print(res)