#include <bits/stdc++.h>
using namespace std;
int tc;
void solve() {
  vector<int> v, v1;
  int n, x, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
    v1.push_back(x);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (v1[i] != v[i]) cnt++;
  }
  if (cnt <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
