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