#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000000;
vector<int> numV;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    numV.push_back(v);
  }
  vector<int> sortV = numV;
  sort(sortV.begin(), sortV.end());
  int ulta_palta = 0;
  for (int i = 0; i < numV.size(); i++) {
    if (numV[i] != sortV[i]) ulta_palta++;
  }
  if (ulta_palta <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
