#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, t;
  int n;
  int a[100005];
  int b[100005];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  int cnt = 0;
  for (i = 0; i < n; i++) {
    if (a[i] != b[i]) cnt++;
  }
  if (cnt == 0 || cnt == 2)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
