#include <bits/stdc++.h>
using namespace std;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
int main() {
  file();
  fast();
  int n;
  cin >> n;
  vector<int> v1(n), copy(n);
  for (int i = 0; i < n; i++) {
    cin >> v1[i];
    copy[i] = v1[i];
  }
  sort(copy.begin(), copy.end());
  int d = 0;
  for (int i = 0; i < n; i++) {
    if (v1[i] != copy[i]) d++;
  }
  if (d == 0 || d == 2)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
  return 0;
}
