#include <bits/stdc++.h>
using namespace std;
int arr[100000], arr2[100000];
vector<int> idx;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr2[i] = arr[i];
  }
  sort(arr2, arr2 + n);
  int nfalse = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] != arr2[i]) idx.push_back(i);
  }
  if ((idx.size() == 2 && arr[idx[0]] == arr2[idx[1]] &&
       arr[idx[1]] == arr2[idx[0]]) ||
      idx.size() == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
