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