#include <bits/stdc++.h>
using namespace std;
void vout(vector<long long> ans) {
  for (auto ele : ans) cout << ele;
}
vector<long long> adj[200001];
bool vis[200001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(8);
  cout << fixed;
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (auto &itr : v) cin >> itr;
  vector<long long> sv;
  sv = v;
  sort((sv).begin(), (sv).end());
  long long cnt = 0;
  string ans = "NO";
  for (long long i = 0; i < n; i++) {
    if (sv[i] != v[i]) cnt++;
  }
  if (cnt <= 2) ans = "YES";
  cout << ans;
  return 0;
}
