#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  long long int second;
  long long int length;
};
int main() {
  long long int n, i;
  cin >> n;
  long long int a[n], b[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  long long int count = 0;
  for (i = 0; i < n && count < 3; i++) {
    if (a[i] != b[i]) count++;
  }
  if (count < 3)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
