#include <bits/stdc++.h>
using namespace std;
const int maxN = 100005;
int a[maxN], n, b[maxN];
vector<int> q;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) cnt++;
  if (cnt > 2)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
