#include using namespace std; #ifdef LOCAL #include "algo/debug.hpp" #else #define debug(...) ((void)0) #endif #include int main() { constexpr char endl = '\n'; std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin >> n; vector a(n); for(auto&x: a) cin >> x, x--; atcoder::fenwick_tree fw(n); int tt = n * (n - 1) / 2; for(int i = 0; i < n; i++) { tt -= fw.sum(0, a[i]); fw.add(a[i], 1); } cout << (tt & 1 ? -1 : 1) << endl; }