#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
double rast(int x1, int y1, int x2, int y2) {
  return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> b = a;
  sort(a.begin(), a.end());
  int kol = 0;
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) kol++;
  if (kol == 2 || kol == 0)
    cout << "YES";
  else
    cout << "NO";
}
