Not getting one test case correct


#1

This is my code

class Solution:
def solve(self, A):
A.sort()
n=len(A)
l=0
y=0
for i in range(n):
for j in range(n):
if(A[i]<A[(i+j)%n]):
l+=1
if(l==A[i]):
y+=1
l=0
if(y!=0):
return 1
elif(A[n-1]==0 and y==0):
return 1
else:
return -1

For the array [ 4, -9, 8, 5, -1, 7, 5, 3 ] it is returning -1 when it should be returning 1. What is wrong in this program?