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