Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

def func(y, x):
    for i in range(60):
        if x == 0:
            continue
        y[i] += x & 1
        x = x >> 1
    return y

ys = reduce(func, xs, [0]*60)
ans = 0

for i,yi in enumerate(ys):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)


Fixed submission:
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = [0]*60
for x in xs:
    for i in range(60):
        if x == 0:
            continue
        ys[i] += x & 1
        x = x >> 1

ans = 0

for i,yi in enumerate(ys):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

y = [0]*60
for x in xs:
    for i in range(60):
        if x == 0:
            continue
        y[i] += x & 1
        x = x >> 1

ans = 0
for i,yi in enumerate(y):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)


Fixed submission:
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = [0]*60
for x in xs:
    for i in range(60):
        if x == 0:
            continue
        ys[i] += x & 1
        x = x >> 1

ans = 0

for i,yi in enumerate(ys):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = []
k = 0
for x in xs:
    y = list(reversed(bin(x)))[:-2]
    ys.append(y)
    k = max(k, len(y))
#print(ys, n)




def calc2(ans, i):
    def calc (x,y):
        if i < len(y) and y[i] == "1":
            return x+1
        else:
            return x
    x1 = 0
    x1 = reduce(calc,ys,0)
    #print(x1,x0)
    ans += x1 * (len(ys)-x1) * (2**(i))
    ans %= 10**9 + 7
    return ans
ans = reduce(calc2, range(k), 0)
print(ans)


Fixed submission:
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = [0]*60
for x in xs:
    for i in range(60):
        if x == 0:
            continue
        ys[i] += x & 1
        x = x >> 1

ans = 0

for i,yi in enumerate(ys):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = []
k = 0
for x in xs:
    y = list(reversed(bin(x)))[:-2]
    ys.append(y)
    k = max(k, len(y))
#print(ys, n)

def calc (x,y):
    if i < len(y) and y[i] == "1":
        return x+1
    else:
        return x

ans = 0
for i in range(k):
    x1 = 0
    x1 = reduce(calc,ys,0)
    #print(x1,x0)
    ans += x1 * (len(ys)-x1) * (2**(i))
    ans %= 10**9 + 7
print(ans)


Fixed submission:
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = [0]*60
for x in xs:
    for i in range(60):
        if x == 0:
            continue
        ys[i] += x & 1
        x = x >> 1

ans = 0

for i,yi in enumerate(ys):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = []
n = 0
for x in xs:
    y = list(reversed(bin(x)))[:-2]
    ys.append(y)
    n = max(n, len(y))
#print(ys, n)

def calc (x,y):
    if i < len(y) and y[i] == "1":
        return x+1
    else:
        return x

ans = 0
for i in range(n):
    x1 = 0
    x1 = reduce(calc,ys,0)
    #print(x1,x0)
    ans += x1 * (len(ys)-x1) * (2**(i))
    ans %= 10**9 + 7
print(ans)


Fixed submission:
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = [0]*60
for x in xs:
    for i in range(60):
        if x == 0:
            continue
        ys[i] += x & 1
        x = x >> 1

ans = 0

for i,yi in enumerate(ys):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = []
n = 0
for x in xs:
    y = list(reversed(bin(x)))[:-2]
    ys.append(y)
    n = max(n, len(y))
#print(ys, n)
ans = 0
for i in range(n):
    x0 = 0
    x1 = 0
    for y in ys:
        #print(y,i,len(y))
        if i < len(y):
            if y[i] == "1":
                x1 += 1
            else:
                x0 +=1
        else:
            x0 += 1
    #print(x1,x0)
    ans += x1 * x0 * (2**(i))
    ans %= 10**9 + 7
print(ans)


Fixed submission:
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = [0]*60
for x in xs:
    for i in range(60):
        if x == 0:
            continue
        ys[i] += x & 1
        x = x >> 1

ans = 0

for i,yi in enumerate(ys):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)