#include using namespace std; #define REP(i,n) for(int i=0;i<(int)(n);++i) #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) #define ALL(c) (c).begin(), (c).end() #define valid(y,x,h,w) (0<=y&&y pii; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (bbasic_ostream& operator<<(basic_ostream&os, const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';} templateostream&operator<<(ostream &o,const pair&t){return o<<'('<void output(ostream&,const Tp&){} templatevoid output(ostream &o,const Tp&t){if(N)o<<',';o<(t);output(o,t);} templateostream&operator<<(ostream&o,const tuple&t){o<<'(';output<0,tuple,Ts...>(o,t);return o<<')';} templatevoid output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20]; int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);} templatevoid outputs(T t){output(t);} templatevoid outputs(S a,T...t){output(a,32);outputs(t...);} templatevoid output(T *a,int n){REP(i,n)cout<void output(T *a,int n,int m){REP(i,n)output(a[i],m);} templatebool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;); if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;} templatebool input(S&a,T&...t){input(a);return input(t...);} templatebool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;} bool check(const vector &v) { int n = v.size(); vector visited(n); vector fuga(n+1); REP(i,n) { if (!visited[i]) { visited[i] = 1; queue Q; Q.push(i); vector hoge; while(!Q.empty()) { int p = Q.front(); Q.pop(); int u = v[p]; hoge.push_back(p); if (!visited[u]) { visited[u] = 1; Q.push(u); } } int cc = 0; sort(ALL(hoge)); REP(j,hoge.size()) { REP(k,j) { if (v[hoge[k]]>v[hoge[j]]) cc++; } } if (cc & 1) fuga[hoge.size()]++; } } for (auto i : fuga) if (i&1) return 0; return 1; } int main() { // { // int n = 8; // vector p(n); // REP(i,n)p[i]=i; // map,vector > S; // do { // auto q = p; // REP(i,n) q[i] = p[p[i]]; // S[q] = p; // } while(next_permutation(ALL(p))); // do { // int cnt = 0; // REP(i,n) { // REP(j,i) if (p[j]>p[i])cnt++; // } // if ((!check(p)) ^ (S.count(p) == 0)) { // cout << p << " " << cnt << " " << check(p) << " " << S[p] << endl; // } else { // // cout << mycount(p) << endl; // } // } while(next_permutation(ALL(p))); // } int n; while(cin >> n) { vector v(n); REP(i,n) { input(v[i]); v[i]--; } int cnt = 0; REP(i,n) { REP(j,i) if (v[j]>v[i])cnt++; } cout << (check(v) ? "Yes" : "No") << endl; } }