#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int* arr = new int[n];
  vector<int> s(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    s[i] = arr[i];
  }
  sort(s.begin(), s.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != arr[i]) cnt++;
  }
  if (cnt <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
