#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<int> s = arr;
  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";
  else
    cout << "NO";
  return 0;
}
