#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> a, ll;
  a.clear();
  ll.clear();
  int n;
  cin >> n;
  if (n <= 2) {
    for (int i = 0; i < n; i++) {
      long long b;
      cin >> b;
    }
    cout << "YES" << endl;
  } else {
    long long b;
    cin >> b;
    a.push_back(b);
    ll.push_back(b);
    int c = 0;
    for (int i = 1; i < n; i++) {
      cin >> b;
      a.push_back(b);
      ll.push_back(b);
    }
    sort(ll.begin(), ll.end());
    for (int i = 0; i < n; i++) {
      if (a[i] != ll[i]) c++;
    }
    if (c > 2)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
