#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int arr[N], arr2[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    arr2[i] = arr[i];
  }
  sort(arr2 + 1, arr2 + n + 1);
  vector<int> whatSwap;
  for (int i = 1; i <= n; i++)
    if (arr2[i] != arr[i]) whatSwap.push_back(i);
  if (whatSwap.size() != 2 && whatSwap.size() != 0) {
    cout << "NO\n";
    return 0;
  }
  if (whatSwap.size() == 0) {
    cout << "YES\n";
    return 0;
  }
  swap(arr[whatSwap[0]], arr[whatSwap[1]]);
  for (int i = 1; i <= n; i++) {
    if (arr[i] != arr2[i]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
