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