#include <bits/stdc++.h>
using namespace std;
static const int MAXN = 1e5 + 10;
static const int OO = 0x3fffffff;
inline int read() {
  int ret = 0, f = 1;
  char c;
  while (c = getchar(), !isdigit(c)) f = c == 45 ? -1 : 1;
  while (isdigit(c)) {
    ret = (ret << 3) + (ret << 1);
    ret += c - 48;
    c = getchar();
  }
  return f * ret;
}
int n;
int a[MAXN];
int b[MAXN];
int main() {
  n = read();
  int dif = 0;
  int p = 1;
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; ++i) {
    if (a[i] != b[i]) {
      ++dif;
    }
  }
  if (dif > 2) {
    puts("NO");
  } else {
    puts("YES");
  }
}
