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