#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *arr = new int[n];
  int *sorted = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sorted[i] = arr[i];
  }
  sort(sorted, sorted + n);
  int dif = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] != sorted[i]) dif++;
    if (dif > 2) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
