#include <bits/stdc++.h>
using namespace std;
int a[100002], s[100002];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int i;
    int k, mx = 1000000000;
    int f = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      s[i] = a[i];
    }
    sort(a, a + n);
    for (i = 0; i < n; i++) {
      if (s[i] != a[i]) f++;
    }
    if (f > 2)
      printf("NO\n");
    else
      printf("YES\n");
  }
  return 0;
}
