#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a[n], f = -1, s = -1, a2[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a2[i] = a[i];
  }
  sort(a2, a2 + n);
  bool flag = true;
  for (int i = 0; i < n; ++i) {
    if (a[i] != a2[i] && f == -1) {
      f = i;
    }
    if (a[i] != a2[i]) s = i;
  }
  if (s != -1 && f != -1) {
    swap(a[s], a[f]);
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] != a2[i]) flag = false;
  }
  if (flag)
    cout << "YES";
  else
    cout << "NO";
}
