#include <bits/stdc++.h>
using namespace std;
vector<long long> a, b;
long long n;
int main() {
  cin >> n;
  long long i, cnt = 0;
  for (i = 0; i < n; i++) {
    long long q;
    cin >> q;
    a.push_back(q);
    b.push_back(q);
  }
  sort(b.begin(), b.end());
  for (i = 0; i < n; i++)
    if (a[i] != b[i]) cnt++;
  if (cnt <= 2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
