_,S=input(),(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)