#include <bits/stdc++.h>
using namespace std;
int arr[100001] = {0};
int sortedArr[100001] = {0};
int main() {
  int n, number = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i], sortedArr[i] = arr[i];
  }
  sort(sortedArr, sortedArr + n);
  for (int i = 0; i < n; i++) {
    if (arr[i] != sortedArr[i]) {
      number++;
    }
    if (ceil(number / 2.0) > 1) {
      break;
    }
  }
  if (ceil(number / 2.0) > 1) {
    cout << "NO";
    return 0;
  }
  cout << "YES";
  return 0;
}
