_,S=input(),list(map(lambda k:int(k),(input()).split(" "))) print(-1 if sum(len([0 for p in S[:i] if int(p) > int(k)]) for i, k in enumerate(S)) % 2 else 1)