#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, -1, 0};
int dy[] = {1, 0, 0, -1};
long long pw(long long b, long long p) {
  if (!p) return 1;
  long long sq = pw(b, p / 2);
  sq *= sq;
  if (p % 2) sq *= b;
  return sq;
}
const int N = 1e5, M = (N << 1);
int *a, *b, *cc;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  a = new int[n], b = new int[n], cc = new int[n];
  for (int i = 0; i < n; i++) cin >> a[i], b[i] = a[i], cc[i] = a[i];
  sort(b, b + n);
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      c++;
    }
  }
  if (c > 2) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES";
  return 0;
}
