#include <bits/stdc++.h>
using namespace std;
int mas[100000];
int mas1[100000];
int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> mas[i];
    mas1[i] = mas[i];
  }
  sort(mas, mas + n);
  for (int i = 0; i < n; i++) {
    if (mas[i] != mas1[i]) cnt++;
  }
  cout << (cnt > 2 ? "NO" : "YES");
}
