Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 10**9 + 7
    n = I()
    a = LI()
    ans = 0
    for i in range(60):
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
        ans += ((n-c1)*c1*(2**i)%mod)%mod
    print(ans%mod)

Fixed submission:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 10**9 + 7
    n = I()
    a = LI()
    ans = 0
    for i in range(60):
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
        ans += ((n-c1)*c1*(2**i)%mod)%mod
    print(ans%mod)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 1000000007
    n = I()
    a = LI()
    a.sort(reverse=True)
    ans = 0
    dig = int(math.log2(a[0])) + 1
    for i in range(dig):
        c0 = 0
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
            else:
                c0 += 1
        ans += (c0*c1*2**i)%mod
    ans %= mod
    print(ans)

Fixed submission:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 10**9 + 7
    n = I()
    a = LI()
    ans = 0
    for i in range(60):
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
        ans += ((n-c1)*c1*(2**i)%mod)%mod
    print(ans%mod)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 1000000007
    n = I()
    a = LI()
    a.sort(reverse=True)
    ans = 0
    dig = int(math.log2(a[0])) + 1
    for i in range(dig):
        c0 = 0
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
            else:
                c0 += 1
        ans += (c0*c1*2**i)%mod
    	ans %= mod
    print(ans)

Fixed submission:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 10**9 + 7
    n = I()
    a = LI()
    ans = 0
    for i in range(60):
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
        ans += ((n-c1)*c1*(2**i)%mod)%mod
    print(ans%mod)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
from collections import deque
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

def main():
    mod = 10**9+7
    n = I()
    a = LI()
    a.sort(reverse=True)
    ans = 0
    dig = int(math.log2(a[0])) + 1
    for i in range(dig):
        c0 = 0
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
            else:
                c0 += 1
        ans += c0*c1*2**i
    ans %= mod
    print(ans)
    return

if __name__=='__main__':
    main()

Fixed submission:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 10**9 + 7
    n = I()
    a = LI()
    ans = 0
    for i in range(60):
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
        ans += ((n-c1)*c1*(2**i)%mod)%mod
    print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = list(map(int, input().split()))

sum  = 0
for i in range(N):
    for j in range(i+1,N):
        sum+=A[i]^A[j]

div = pow(10,9)+7

print(sum%div)

Fixed submission:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 10**9 + 7
    n = I()
    a = LI()
    ans = 0
    for i in range(60):
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
        ans += ((n-c1)*c1*(2**i)%mod)%mod
    print(ans%mod)