#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
int main() {
  int n;
  cin >> n;
  std::vector<int> m(n);
  std::vector<int> o(n);
  for (int i = 0; i < n; ++i) {
    cin >> m[i];
    o[i] = m[i];
  }
  std::sort(m.begin(), m.end());
  int diff = 0;
  for (int i = 0; i < n; ++i) {
    if (m[i] != o[i]) {
      diff++;
    }
  }
  if (diff == 0 || diff == 2) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
