N=int(input())+1;a,l,c,r=N,[1],0,{} while cb),l][i in r];r[i]=1 print([-1,a][a