Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
A = map(int, raw_input().split())
A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    zeros = len([a[i] for a in A if a[i] == '0'])
    ones = N - zeros
    count[i] = zeros*ones

mod_val = dict()
curr = 1
for i in range(60):
    mod_val[i] = curr % MOD
    curr = (2*curr) % MOD

ans = 0
for i in count:
    ans = (ans + count[i]*mod_val[59-i]) % MOD

print ans


Fixed submission:
import numpy as np

N = int(raw_input())
A = np.array(map(int, raw_input().split()))
# A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    # zeros = len([a[i] for a in A if a[i] == '0'])
    zeros = np.count_nonzero((A>>i)&1)
    ones = N - zeros
    count[i] = zeros*ones

mod_val = dict()
curr = 1
for i in range(60):
    mod_val[i] = curr % MOD
    curr = (2*curr) % MOD

ans = 0
for i in count:
    ans = (ans + count[i]*mod_val[i]) % MOD

print ans

Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
A = map(int, raw_input().split())
A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    zeros = len([a[i] for a in A if a[i] == '0'])
    ones = N - zeros
    count[i] = zeros*ones

ans = 0
for i, v in count.items():
    ans = (ans + count[i]*((1<<(59-i)) % MOD)) % MOD

print ans


Fixed submission:
import numpy as np

N = int(raw_input())
A = np.array(map(int, raw_input().split()))
# A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    # zeros = len([a[i] for a in A if a[i] == '0'])
    zeros = np.count_nonzero((A>>i)&1)
    ones = N - zeros
    count[i] = zeros*ones

mod_val = dict()
curr = 1
for i in range(60):
    mod_val[i] = curr % MOD
    curr = (2*curr) % MOD

ans = 0
for i in count:
    ans = (ans + count[i]*mod_val[i]) % MOD

print ans

Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
A = map(int, raw_input().split())
A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    zeros = len([a[i] for a in A if a[i] == '0'])
    ones = N - zeros
    count[i] = zeros*ones

ans = 0
for i, v in count.items():
    ans = (ans + count[i]*(1<<(59-i))) % MOD

print ans


Fixed submission:
import numpy as np

N = int(raw_input())
A = np.array(map(int, raw_input().split()))
# A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    # zeros = len([a[i] for a in A if a[i] == '0'])
    zeros = np.count_nonzero((A>>i)&1)
    ones = N - zeros
    count[i] = zeros*ones

mod_val = dict()
curr = 1
for i in range(60):
    mod_val[i] = curr % MOD
    curr = (2*curr) % MOD

ans = 0
for i in count:
    ans = (ans + count[i]*mod_val[i]) % MOD

print ans

Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
A = map(int, raw_input().split())
A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    zeros = len([a[i] for a in A if a[i] == '0'])
    ones = len([a[i] for a in A if a[i] == '1'])
    count[i] = zeros*ones

ans = 0
for i, v in count.items():
    ans = (ans + count[i]*(2**(59-i))) % MOD

print ans


Fixed submission:
import numpy as np

N = int(raw_input())
A = np.array(map(int, raw_input().split()))
# A = map(lambda x: format(x, '060b'), A)
MOD = 10**9 + 7

count = dict()
for i in range(60):
    # zeros = len([a[i] for a in A if a[i] == '0'])
    zeros = np.count_nonzero((A>>i)&1)
    ones = N - zeros
    count[i] = zeros*ones

mod_val = dict()
curr = 1
for i in range(60):
    mod_val[i] = curr % MOD
    curr = (2*curr) % MOD

ans = 0
for i in count:
    ans = (ans + count[i]*mod_val[i]) % MOD

print ans