#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100000 + 10;
const int INF = 0x7f7f7f7f;
const double eps = 1e-10;
const double pi = acos(-1.0);
inline int realcmp(double a, double b) {
  return (a > b + eps) ? 1 : ((a + eps < b) ? -1 : 0);
}
int a[Maxn], b[Maxn];
int main() {
  int cnt = 0, n;
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) cnt++;
  if (cnt <= 2)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
