#include <bits/stdc++.h>
using namespace std;
void solve(vector<int>& a, int n) {
  vector<int> b(a);
  sort(a.begin(), a.end());
  int c = 0;
  vector<int> pos;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] != b[i]) {
      c++;
      pos.push_back(i);
    }
  }
  if (c == 1 || c > 2) {
    cout << "NO";
  } else if (c == 0) {
    cout << "YES";
  } else {
    int x = pos[0];
    int y = pos[1];
    if (a[x] == b[y] && b[x] == a[y])
      cout << "YES";
    else
      cout << "NO";
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  solve(a, n);
  return 0;
}
