#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int a[N], b[N];
int main() {
  int n, count = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) count++;
    if (count == 3) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
