#include <bits/stdc++.h>
using namespace std;
int main() {
  long i, j, k, l, m, n, p, q;
  while (cin >> p) {
    int x[p], y[p];
    for (i = 0; i < p; i++) {
      cin >> x[i];
      y[i] = x[i];
    }
    sort(x, x + p);
    int a = 0;
    for (i = 0; i < p; i++) {
      if (x[i] != y[i]) {
        a++;
        l = 0;
        k = 0;
        for (j = i + 1; j < p; j++)
          if (x[j] != y[j]) {
            k++;
            l = j;
          }
        if (x[i] == y[l] && x[l] == y[i] && k == 1)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
        break;
      }
    }
    if (a == 0) cout << "YES" << endl;
  }
  return 0;
}
