#include <bits/stdc++.h>
using namespace std;
int inp[100000 + 5];
int temp[100000 + 5];
int main() {
  int n, count = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> inp[i];
    temp[i] = inp[i];
  }
  sort(temp, temp + n);
  for (int i = 0; i < n; i++) {
    if (inp[i] != temp[i]) count++;
  }
  if (count <= 2)
    cout << "YES";
  else
    cout << "NO";
}
