#include <bits/stdc++.h>
using namespace std;
int d[100010], n;
bool is_sorted() {
  for (int i = 1; i < n; i++) {
    if (d[i - 1] > d[i]) return 0;
  }
  return 1;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> d[i];
  if (is_sorted())
    cout << "YES" << endl;
  else {
    int L = -1, R = -1;
    for (int i = 1; i < n; i++)
      if (d[i] < d[i - 1]) {
        L = i - 1;
        break;
      }
    for (int i = n - 2; i >= 0; i--)
      if (d[i] > d[i + 1]) {
        R = i + 1;
        break;
      }
    while (L && d[L] == d[L - 1]) L--;
    while (R < n - 1 && d[R] == d[R + 1]) R++;
    if (d[L] > d[R]) {
      swap(d[L], d[R]);
      if (is_sorted())
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else {
      int Minp = -1, Maxp = -1;
      for (int i = L + 1; i < R; i++) {
        if (d[i] < d[L]) Minp = i;
        if (d[i] > d[R]) Maxp = i;
      }
      if (Minp != -1 && Maxp != -1)
        cout << "NO" << endl;
      else if (Minp != -1) {
        swap(d[L], d[Minp]);
        if (is_sorted())
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
      } else if (Maxp != -1) {
        swap(d[R], d[Maxp]);
        if (is_sorted())
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
      }
    }
  }
  return 0;
}
