#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int MAXN = 1e7 + 6;
const int MOD = 1e9 + 7;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int n;
vector<int> arr, tarr;
int main() {
  cin >> n;
  arr.resize(n);
  tarr.resize(n);
  for (int i = 0; i < int(n); i++) {
    cin >> arr[i];
    tarr[i] = arr[i];
  }
  sort(arr.begin(), arr.end());
  int cnt = 0;
  for (int i = 0; i < int(n); i++) {
    if (arr[i] != tarr[i]) ++cnt;
  }
  if (cnt > 2)
    puts("NO");
  else
    puts("YES");
  return 0;
}
