#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x;
  vector<int> vec;
  for (int i = 0; i < n; i++) {
    cin >> x;
    vec.push_back(x);
  }
  vector<int> vec1 = vec;
  sort(vec.begin(), vec.end());
  int count = 0;
  for (int i = 0; i < n; i++)
    if (vec[i] != vec1[i]) count++;
  if (count == 2 || count == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
