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