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