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