#include <bits/stdc++.h>
using namespace std;
template <class T>
void checkmin(T &t, T x) {
  if (x < t) t = x;
}
template <class T>
void checkmax(T &t, T x) {
  if (x > t) t = x;
}
template <class T>
void _checkmin(T &t, T x) {
  if (t == -1) t = x;
  if (x < t) t = x;
}
template <class T>
void _checkmax(T &t, T x) {
  if (t == -1) t = x;
  if (x > t) t = x;
}
const int N = 105555;
int n;
int a[N], b[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memcpy(b, a, sizeof(b));
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++) {
    if (b[i] != a[i]) {
      int j = n;
      while (a[j] != b[i]) j--;
      swap(a[i], a[j]);
      break;
    }
  }
  bool ok = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] != b[i]) ok = 0;
  }
  if (ok) {
    printf("YES");
  } else {
    printf("NO");
  }
}
