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