import sys input = sys.stdin.readline from collections import * class BIT: def __init__(self, n): self.n = n self.bit = [0]*(n+1) def add(self, i, x): i += 1 while i<=self.n: self.bit[i] += x i += i&(-i) def acc(self, i): s = 0 while i>0: s += self.bit[i] i -= i&(-i) return s N = int(input()) S = list(map(int, input().split())) bit = BIT(N) inv = 0 for i in range(N): inv += i-bit.acc(S[i]) bit.add(S[i]-1, 1) if inv%2==0: print(1) else: print(-1)