#include <bits/stdc++.h>
using namespace std;
struct node {
  int val;
  int id;
};
bool compare(struct node a1, struct node a2) {
  if (a1.val < a2.val) return true;
  return false;
}
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  struct node arr[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    arr[i].val = a[i];
    arr[i].id = i;
  }
  sort(arr, arr + n, compare);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i].val != a[i]) cnt++;
  }
  if (cnt <= 2)
    cout << "YES\n";
  else
    cout << "NO\n";
}
