#include <bits/stdc++.h>
using namespace std;
int n, m, k, i, c, b, a, energy, ans, s, j, w[2555555], l[2555555], kol;
pair<int, int> p[2555555];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> w[i];
    l[i] = w[i];
  }
  sort(w + 1, w + 1 + n);
  for (i = 1; i <= n; i++) {
    if (l[i] != w[i]) a++;
    if (a > 2) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
