#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[100000], b[100000], n, cnt = 0;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      b[i] = a[i];
    }
    sort(b, b + n);
    for (int i = 0; i < n; ++i) {
      if (a[i] != b[i]) cnt++;
    }
    if (cnt == 0 || cnt == 2) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
