#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long x, y, n, m, t, q, a, b, count = 0;
  cin >> n;
  long long arr[n];
  for (x = 0; x < n; x++) cin >> arr[x];
  long long cop[n];
  for (x = 0; x < n; x++) cop[x] = arr[x];
  sort(cop, cop + n);
  vector<long long> v;
  for (x = 0; x < n; x++)
    if (arr[x] != cop[x]) count++, v.push_back(x);
  if (count <= 2)
    cout << "YES";
  else
    cout << "NO";
}
