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