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