#include <bits/stdc++.h>
using namespace std;
int n;
int a[100010];
int b[100010];
void init() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  memcpy(b, a, sizeof(a));
  sort(b, b + n);
}
void work() {
  int cont = 0;
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) cont++;
  if (cont > 2)
    printf("NO\n");
  else
    printf("YES\n");
}
int main() {
  init();
  work();
  return 0;
}
