#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n;
  vector<int> a, b;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
    b.push_back(x);
  }
  sort(b.begin(), b.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) cnt++;
  }
  x = cnt % 2;
  cnt /= 2;
  cnt += x;
  if (cnt <= 1)
    cout << "YES\n";
  else
    cout << "NO\n";
}
