#include // #include // #include using namespace std; // using namespace atcoder; // using bint = boost::multiprecision::cpp_int; using ll = long long; using ull = unsigned long long; using P = pair; #define rep(i,n) for(ll i = 0;i < (ll)n;i++) #define ALL(x) (x).begin(),(x).end() #define MOD 1000000007 // #define MOD 998244353 template class BIT{ public: //0-indexed vector s; const int n; BIT (int n_):s(n_+1,0),n(n_){} T sum(int i){ i++; T k = 0; while(i > 0){ k += s[i]; i -= i & (-i); } return k; } // [l,r] T sum(int l,int r){ return sum(r)-sum(l-1); } void add(int pos,T val){ pos++; while(pos <= n){ s[pos] += val; pos += pos & (-pos); } } int lower_bound(T k){ int len = 1; while(len < n)len <<= 1; int l = 0; T x = 0; for(;len > 0;len >>= 1){ if(l+len <= n && s[l+len]+x < k)x += s[l+len],l += len; } return l; } }; int main(){ int n; cin >> n; vector s(n); rep(i,n)cin >> s[i]; BIT bit(n); ll sgn = 0; rep(i,n){ sgn = (sgn + bit.sum(n-1) - bit.sum(s[i]-1))%2; sgn = (sgn + 2)%2; bit.add(s[i]-1,1); } cout << (sgn ? -sgn : 1) << "\n"; return 0; }