N = int(input()) S = list(map(lambda x: int(x)-1, input().split())) xs = S[:] cnt = 0 for i in range(N): if xs[i] == i: continue x = xs[i] xs[i], xs[x] = xs[x], xs[i] cnt += 1 if cnt % 2 == 0: print(1) else: print(-1)