Help me in solving TRICOUNT1 problem

My issue

The code returns a runtime error and I don’t know why because I cannot see what the error actually is… please help me solve this

My code

def solution():
    n = int(input())
    a = list(map(int,input().split(' ')))
    
    X_total = set()
    a.sort()
    for i in range(0,n-1):
        
        x = list(i for i in range(a[i+1]-a[i]+1,a[i]+a[i+1]))
        X_total.update(x) 
    
    return len(X_total)

for _ in range(int(input())):
    print(solution())

Problem Link: Triangle Count (Easy) Practice Coding Problem