#include <bits/stdc++.h>
using namespace std;
const int INF = 2 * (1e9);
int main() {
  int N, cnt = 0;
  cin >> N;
  vector<int> A(N);
  for (int &i : A) {
    cin >> i;
  }
  vector<int> B = A;
  sort(B.begin(), B.end());
  for (int i = 0; i < N; i++) {
    if (A[i] != B[i]) {
      cnt++;
    }
  }
  if (cnt > 2) {
    cout << "NO";
  } else {
    cout << "YES";
  }
  return 0;
}
