#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, input, count = 0, index1, index2;
  cin >> t;
  vector<long long> v1, v2;
  for (int i = 0; i < t; i++) {
    cin >> input;
    v1.push_back(input);
  }
  v2 = v1;
  sort(v2.begin(), v2.end());
  if (v1 == v2) {
    cout << "YES" << endl;
    return 0;
  } else {
    for (int i = 0; i < v2.size(); i++) {
      if (v1[i] != v2[i] && count == 0) {
        index1 = i;
        count = 1;
      } else if (v1[i] != v2[i] && count == 1) {
        index2 = i;
        long long num1 = v1[index1], num2 = v1[index2];
        v1.erase(v1.begin() + index1);
        v1.insert(v1.begin() + index1, num2);
        v1.erase(v1.begin() + index2);
        v1.insert(v1.begin() + index2, num1);
        if (v1 == v2) {
          cout << "YES" << endl;
          return 0;
        } else {
          cout << "NO" << endl;
          return 0;
        }
      }
    }
  }
}
