#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long l;
typedef pair<int, int> pint;
typedef vector<pint> vpint;
typedef vector<int> vint;
typedef vector<vint> vvint;
int n, m, x[123457], cum[1234567];
int ans;
map<int, int> mp;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    cum[i] = x[i];
  }
  sort(cum, cum + n);
  for (int i = 0; i < n; ++i) {
    if (x[i] != cum[i]) ans++;
  }
  if (ans < 3)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
