Help me in solving CHRISCANDY problem

My issue

cook your dish here

t = int(input())
for x in range(t):
size = int(input())
aList = list(map(int,input().split()))
count = 0
for i in range(size):
for j in range(i+1,size):
if(aList[i] > aList[j]):
count_{j} +=1
print(count)

What is wrong in this code for Christmas candy problem?

My code

for i in range(int(input())):
    b=int(input())
    l=list(map(int,input().split()))
    
    x=0
    max1=l[0]
    for i in range(1,len(l)):
        if l[i]<max1:
            x=x+1
        else:
            max1=l[i]
    print(x)
    
        
        

Problem Link: Christmas Candy Practice Coding Problem - CodeChef

@rabinjais7
your code is working fine dude