help in little chef and numbers why this code is giving time limit exceeded error

def fun():
test = input()
test1 = int(test)
for i in range(test1):
num = input()
num1= int(num)
arr = input()
arr1 = arr.split()
arr1 = list(set(arr1))
le= len(arr1)-1
i,j=0,le
count = 0
while(len(arr1)>1):
if(i<j):
m=int(arr1[i])*int(arr1[j])
add=int(arr1[i])+int(arr1[j])
if(m>add):
count+=1
j-=1
else:
arr1.pop()
j=len(arr1)-1

	print (count)

if name==‘main’:
fun()