#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, MOD = 1e9 + 7;
int n, c, x[N], y[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    y[i] = x[i];
  }
  sort(y, y + n);
  for (int i = 0; i < n; i++) {
    if (x[i] != y[i]) c++;
  }
  if (c == 0 || c == 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
