#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int A[100005], B[100005];
  ;
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
  int i = 0, first = 0, second = 0, j = 0;
  for (i = 1; i <= N; i++) B[i] = A[i];
  sort(B + 1, B + N + 1);
  for (i = 1; i <= N; i++) {
    if (A[i] != B[i]) {
      first = i;
      break;
    }
  }
  for (j = i + 1; j <= N; j++) {
    if (A[j] != B[j]) {
      second = j;
      break;
    }
  }
  swap(A[j], A[i]);
  for (i = 1; i <= N; i++)
    if (A[i] != B[i]) {
      cout << "NO" << endl;
      return 0;
    }
  cout << "YES" << endl;
  return 0;
}
