#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  int v[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    v[i] = a[i];
  }
  sort(a, a + n);
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != v[i]) c++;
  }
  printf("%s", c <= 2 ? "YES" : "NO");
  return 0;
}
