#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
const int MAXR = 1;
const int MAXC = 1;
const int INF = (int)1e+9;
long long int arr[MAXN];
long long int arrc[MAXN];
int x4[] = {-1, 0, 1, 0};
int y4[] = {0, 1, 0, -1};
int main(void) {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arrc[i] = arr[i];
  }
  sort(arrc, arrc + n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (arrc[i] != arr[i]) {
      cnt++;
    }
  }
  if (cnt == 0 || cnt == 2) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
