Help me in solving SETDIFF problem

My issue

I have issue with this question, i will write the approach here please help me to solve the problem: from itertools import *
for _ in range(int(input())):
n = int(input())
s = set(map(int,input().split()))
l =
for i in range(1,n+1):
l.append(combinations(s,i))
sum1 = 0
for i in l:
for j in i:
sum1 += max(j) - min(j)
print(sum1)

It gives run time error

My code

# cook your dish here

Problem Link: SETDIFF Problem - CodeChef

@hari44
Plzz refer the following solution for better understanding of the logic and implementation.

m=10**9+7
for _ in range(int(input())):
  n=int(input())
  a=list(map(int,input().split()))
  a.sort()
  ans=0
  for i in range(n):
    ans+=(a[i]*pow(2,i,m)-a[i]*pow(2,n-i-1,m)+m)%m
  print(ans%m)
#rersegfgs