#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,p;
  cin >> N;
  int count;
  for (int i = 0; i < N; i++){
    cin >> p;
    if (i + 1 != p) count++;
  }
  cout << (count == 0 || count == 2 ? "YES" : "NO");
}