#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int a[110000], b[110000];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  int cnt = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (a[i] != b[i]) ++cnt;
  }
  if (cnt <= 2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
