Test cases failing

n =int(input())
l = [int(i) for i in input().split()]

ans = []

for i in range(n):
num = abs(l[i])
if l[num-1] < 0:
ans.append(num)
else:
l[num-1] *= -1

print(ans)

test cases are failing for the above code

 Answer must be sorted

add this