#include <bits/stdc++.h>
const int INF = ~0U >> 1;
using namespace std;
int a[100005], b[100005], rec[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++) {
    if (a[i] != b[i]) {
      if (ans >= 3) {
        cout << "NO\n";
        return 0;
      } else {
        ans++;
        rec[ans] = i;
      }
    }
  }
  if (ans <= 1) {
    cout << "YES\n";
    return 0;
  }
  if (a[rec[1]] == b[rec[2]] && b[rec[1]] == a[rec[2]]) {
    cout << "YES\n";
    return 0;
  } else {
    cout << "NO\n";
  }
  return 0;
}
