#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v, vv;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
    vv.push_back(x);
  }
  sort(vv.begin(), vv.end());
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i] != vv[i]) {
      cnt++;
    }
  }
  if (cnt < 3)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
