same test cases are passed successfully but after submitting showing fail for the same test cases

t=int(input())
s=set()
l3=[]
flag=False
for i in range(t):
n=int(input())
l1=list(map(int,input().split()))
l2=l1
for j in range(len(l1)):
for k in range(len(l2)):
if(l1[j]==l2[k]):
l3.append(l1[j])

s=set(l3)
for i in s:
    if(l1.count(i)%i!=0):
        flag=True
        break
if(flag==True):
    print("NO")
else:
    print("YES")

@iitm21f2000159 - please confirm the problem code.