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