#include <bits/stdc++.h>
using namespace std;
vector<int> a;
vector<int> b;
int n;
void get_input() { cin >> n; }
void solve() {
  for (int i = 0; i < n; i++) {
    int kom;
    cin >> kom;
    a.push_back(kom);
    b.push_back(kom);
  }
  sort(b.begin(), b.begin() + n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] != a[i]) {
      cnt++;
    }
  }
  cout << (cnt > 2 ? "NO" : "YES");
}
void output() {}
int main() {
  ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) {
    get_input(), solve(), output();
  }
  return 0;
}
