#include <bits/stdc++.h>
using namespace std;
int n, a;
vector<int> v1, v2;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v1.push_back(a);
    v2.push_back(a);
  }
  sort(v2.begin(), v2.end());
  a = 0;
  for (int i = 0; i < n; i++) {
    a += v1[i] != v2[i];
  }
  (a < 3) ? cout << "YES" << endl : cout << "NO" << endl;
  return 0;
}
