#include <bits/stdc++.h>
using namespace std;
class ProblemALittleElephantAndProblem {
 public:
  int arr[100005], b[100005];
  int n;
  void solve(std::istream& in, std::ostream& out) {
    in >> n;
    for (int i = 0; i < n; ++i) in >> arr[i], b[i] = arr[i];
    sort(b, b + n);
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      if (arr[i] != b[i]) ++cnt;
    }
    if (cnt <= 2)
      out << "YES";
    else
      out << "NO";
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ProblemALittleElephantAndProblem solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
