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