#include <bits/stdc++.h>
using namespace std;
const int maxn = 100001;
int n, a[maxn], sorted[maxn], diff;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    sorted[i] = a[i];
  }
  sort(sorted + 1, sorted + 1 + n);
  for (int i = 1; i <= n; ++i) {
    diff += (sorted[i] != a[i]);
  }
  puts(diff <= 2 ? "YES" : "NO");
  return 0;
}
