#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005], sa[100005];
bool isSorted(int i, int j) {
  if ((i && a[i - 1] > a[i]) || (a[i] > a[i + 1])) return false;
  if ((j && a[j - 1] > a[j]) || (a[j] > a[j + 1])) return false;
  return true;
}
bool ok() {
  int first = -1;
  sa[n] = a[n] = 2000000009;
  for (int i = 0; i < (n); ++i) {
    if (a[i] == sa[i]) continue;
    first = i;
    break;
  }
  if (first == -1) return true;
  for (int second = first + 1; second < (n); ++second) {
    if (a[second] != sa[second]) {
      swap(a[first], a[second]);
      break;
    }
  }
  for (int i = 0; i < (n); ++i)
    if (a[i] != sa[i]) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &a[i]);
    sa[i] = a[i];
  }
  sort(sa, sa + n);
  printf("%s", ok() ? "YES" : "NO");
  return 0;
}
