Buggy python submission (verdict: Time Limit Exceeded):
N = 60
MOD = 10**9 + 7
n = int(input())
c0 = [0 for _ in range(N)]
c1 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) == 0:
            c0[j] += 1
        else:
            c1[j] += 1

ans = 0
for i in range(n-1):
    for j in range(N):
        if a[i] & (1 << j) == 0:
            c0[j] -=1
        else:
            c1[j] -=1
    for j in range(N):
        if a[i] & (1 << j) == 0:
            ans += (1<<j) * c1[j]
        else:
            ans += (1<<j) * c0[j]

print(ans % MOD)

Fixed submission:
N = 60
MOD = 10**9 + 7
n = int(input())
# c1 = [0 for _ in range(N)]
c1 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] += 1
        # else:
        #     c1[j] += 1

ans = 0
for i in range(n-1):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] -=1
        # else:
        #     c0[j] -=1
    for j in range(N):
        if a[i] & (1 << j) != 0:
            ans += (1<<j) * (n-i-1-c1[j])
        else:
            ans += (1<<j) * c1[j]
            #ans += (1<<j) * c1[j]

print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N = 60
MOD = 10**9 + 7
n = int(input())
l = [[] for _ in range(n)]
# c1 = [0 for _ in range(N)]
c0 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            # c1[j] += 1
            l[i].append(True)
        else:
            c0[j] += 1
            l[i].append(False)

ans = 0
for i in range(n-1):
    for j in range(N):
        if not l[i][j]:
            c0[j] -=1
        # else:
        #     c0[j] -=1
    for j in range(N):
        if l[i][j]:
            ans += (1<<j) * c0[j]
        else:
            ans += (1<<j) * (n-i-1-c0[j])
            #ans += (1<<j) * c1[j]

print(ans % MOD)

Fixed submission:
N = 60
MOD = 10**9 + 7
n = int(input())
# c1 = [0 for _ in range(N)]
c1 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] += 1
        # else:
        #     c1[j] += 1

ans = 0
for i in range(n-1):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] -=1
        # else:
        #     c0[j] -=1
    for j in range(N):
        if a[i] & (1 << j) != 0:
            ans += (1<<j) * (n-i-1-c1[j])
        else:
            ans += (1<<j) * c1[j]
            #ans += (1<<j) * c1[j]

print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N = 60
MOD = 10**9 + 7
n = int(input())
l = [[] for _ in range(n)]
c1 = [0 for _ in range(N)]
c0 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] += 1
            l[i].append(True)
        else:
            c0[j] += 1
            l[i].append(False)

ans = 0
for i in range(n-1):
    for j in range(N):
        if l[i][j]:
            c1[j] -=1
        else:
            c0[j] -=1
    for j in range(N):
        if l[i][j]:
            ans += (1<<j) * c0[j]
        else:
            ans += (1<<j) * c1[j]

print(ans % MOD)

Fixed submission:
N = 60
MOD = 10**9 + 7
n = int(input())
# c1 = [0 for _ in range(N)]
c1 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] += 1
        # else:
        #     c1[j] += 1

ans = 0
for i in range(n-1):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] -=1
        # else:
        #     c0[j] -=1
    for j in range(N):
        if a[i] & (1 << j) != 0:
            ans += (1<<j) * (n-i-1-c1[j])
        else:
            ans += (1<<j) * c1[j]
            #ans += (1<<j) * c1[j]

print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N = 60
MOD = 10**9 + 7
n = int(input())
l = [[] for _ in range(n)]
c1 = [0 for _ in range(N)]
c0 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] += 1
            l[i].append(True)
        else:
            c0[j] += 1
            l[i].append(False)

ans = 0
for i in range(n-1):
    for j in range(N):
        if l[i][j]:
            c1[j] -=1
        else:
            c0[j] -=1
    for j in range(N):
        if l[i][j]:
            ans += (1<<j) * c0[j]
        else:
            ans += (1<<j) * c1[j]

print(ans % MOD)

Fixed submission:
N = 60
MOD = 10**9 + 7
n = int(input())
# c1 = [0 for _ in range(N)]
c1 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] += 1
        # else:
        #     c1[j] += 1

ans = 0
for i in range(n-1):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] -=1
        # else:
        #     c0[j] -=1
    for j in range(N):
        if a[i] & (1 << j) != 0:
            ans += (1<<j) * (n-i-1-c1[j])
        else:
            ans += (1<<j) * c1[j]
            #ans += (1<<j) * c1[j]

print(ans % MOD)