#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int mas[100001];
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> mas[i];
    v.push_back(mas[i]);
  }
  sort(v.begin(), v.end());
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (mas[i] != v[i]) sum++;
  }
  if (sum > 2)
    cout << "NO";
  else
    cout << "YES";
}
