#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; int main(){ int N; cin >> N; vi A(N), B(N), C(N+1); rep(i, N)cin >> A[i], --A[i]; rep(i, N){ if(B[i])continue; int k = i, c = 0; do{ c++; k = A[k]; B[k] = 1; } while(k != i); C[c]++; } int x = 1; rep(i, N + 1)if(!(i & 1) && C[i] & 1)x = 0; puts(x ? "YES" : "NO"); }