Buggy python submission (verdict: Time Limit Exceeded):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = dict()
    pow_list = dict()
    for j in range(60): 
        bit[j] = 0
        pow_list[j] = pow(2, j, mod)

    first = A[0]
    for j in range(60):
        bit[j] = first % 2
        first //= 2
    
    ans = 0
    for i in range(1, N):
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (i - bit[j]) * pow_list[j]
                ans %= mod
            else:
                ans += bit[j] * pow_list[j]
                ans %= mod
            bit[j] += (num % 2)
            num //=2
            
    print(ans)

    return 0

if __name__ == "__main__":
    solve()


Fixed submission:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = dict()
    pow_list = dict()
    for j in range(60): 
        bit[j] = 0
        pow_list[j] = pow(2, j, mod)

    first = A[0]
    for j in range(60):
        bit[j] = first % 2
        first //= 2
    
    ans = 0
    for i in range(1, N):
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (i - bit[j]) * pow_list[j]
                ans %= mod
            else:
                ans += bit[j] * pow_list[j]
                ans %= mod
            bit[j] += (num % 2)
            num //=2
            
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = [0 for _ in range(60)] 

    last = A[N-1]
    for j in range(60):
        bit[j] = last % 2
        last //= 2
    
    ans = 0
    for i in reversed(range(N-1)):
        total = N - 1 - i
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (total - bit[j]) * pow(2, j, mod)
                ans %= mod
            else:
                ans += bit[j] * pow(2, j, mod)
                ans %= mod
            bit[j] += (num % 2)
            num //=2
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = dict()
    pow_list = dict()
    for j in range(60): 
        bit[j] = 0
        pow_list[j] = pow(2, j, mod)

    first = A[0]
    for j in range(60):
        bit[j] = first % 2
        first //= 2
    
    ans = 0
    for i in range(1, N):
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (i - bit[j]) * pow_list[j]
                ans %= mod
            else:
                ans += bit[j] * pow_list[j]
                ans %= mod
            bit[j] += (num % 2)
            num //=2
            
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = dict()
    for i in range(N):
        bit[i] = dict()
        for j in range(60):
            bit[i][j] = 0
            
    last = A[N-1]
    for j in range(60):
        bit[N-1][j] = last % 2
        last //= 2
    
    ans = 0
    for i in reversed(range(N-1)):
        total = N - 1 - i
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (total - bit[i+1][j]) * pow(2, j, mod)
                ans %= mod
            else:
                ans += bit[i+1][j] * pow(2, j, mod)
                ans %= mod
            bit[i][j] = bit[i+1][j]  + (num % 2)
            num //=2
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = dict()
    pow_list = dict()
    for j in range(60): 
        bit[j] = 0
        pow_list[j] = pow(2, j, mod)

    first = A[0]
    for j in range(60):
        bit[j] = first % 2
        first //= 2
    
    ans = 0
    for i in range(1, N):
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (i - bit[j]) * pow_list[j]
                ans %= mod
            else:
                ans += bit[j] * pow_list[j]
                ans %= mod
            bit[j] += (num % 2)
            num //=2
            
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = dict()
    for i in range(N):
        bit[i] = dict()
        for j in range(60):
            bit[i][j] = 0
    last = A[N-1]
    for j in range(60):
        bit[N-1][j] = last % 2
        last //= 2
    ans = 0
    for i in reversed(range(N-1)):
        total = N - 1 - i
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (total - bit[i+1][j]) * pow(2, j, mod)
                ans %= mod
            else:
                ans += bit[i+1][j] * pow(2, j, mod)
                ans %= mod
            bit[i][j] = bit[i+1][j]  + (num % 2)
            num //=2
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Fixed submission:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = dict()
    pow_list = dict()
    for j in range(60): 
        bit[j] = 0
        pow_list[j] = pow(2, j, mod)

    first = A[0]
    for j in range(60):
        bit[j] = first % 2
        first //= 2
    
    ans = 0
    for i in range(1, N):
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (i - bit[j]) * pow_list[j]
                ans %= mod
            else:
                ans += bit[j] * pow_list[j]
                ans %= mod
            bit[j] += (num % 2)
            num //=2
            
    print(ans)

    return 0

if __name__ == "__main__":
    solve()