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