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