#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100000], b[100000];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] != b[i]) ans++;
  }
  if (ans <= 2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
