#include <bits/stdc++.h>
using namespace std;
long long expo(long long a, long long b, long long m) {
  long long result = 1;
  while (b) {
    if (b & 1) {
      result = (result * a) % m;
    }
    b = (b >> 1) % m;
    a = (a * a) % m;
  }
  return result;
}
bool comp(pair<int, int> a, pair<int, int> b) {
  return ((abs)(a.first) + (abs)(a.second)) <
         ((abs)(b.first) + (abs)(b.second));
}
int a[1005][1005] = {0};
int main() {
  vector<long long> a;
  int n;
  long long temp;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> temp;
    a.push_back(temp);
  }
  vector<long long> b = a;
  sort(a.begin(), a.end());
  int c = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] != b[i]) {
      c++;
    }
  }
  if (c <= 2) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
