#include using namespace std; template struct BIT { int n; // 配列の要素数(数列の要素数+1) vector bit; // データの格納先 BIT(int n_) : n(n_ + 1), bit(n, 0) {} void add(int i, T x) { for (int idx = i; idx < n; idx += (idx & -idx)) { bit[idx] += x; } } T sum(int i) { T s(0); for (int idx = i; idx > 0; idx -= (idx & -idx)) { s += bit[idx]; } return s; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int cnt = 0; BIT bit(n + 1); for (int i = 0; i < n; i++) { cnt += i - bit.sum(a[i]); bit.add(a[i], 1); } cout << (cnt & 1 ? -1 : 1) << '\n'; }