Beta relese (in python) task

with open("input.txt", "r") as f:
    N = int(f.readline().strip())
    v = list(map(int, f.readline().strip().split()))
    cont=0
    v.sort()
    v=set(v)

    temp=N
    if(len(v)==N-1):
       
        with open("output.txt", "w") as f:
            f.write(str("NO") + "\n")
    elif len(v)<=N-2:
        
        with open("output.txt", "w") as f:
            f.write(str("YES") + "\n")

non capisco dove sbaglio mi da alcuni test case giusti ed altri sbagliati