#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int arr[n], sorted[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sorted[i] = arr[i];
  }
  sort(sorted, sorted + n);
  vector<pair<int, int> > misplaced_elements;
  for (int i = 0; i < n; i++) {
    if (arr[i] != sorted[i]) {
      misplaced_elements.push_back(make_pair(arr[i], i));
    }
  }
  if (misplaced_elements.size() == 0) {
    cout << "YES";
  } else if (misplaced_elements.size() == 2) {
    vector<pair<int, int> >::iterator itr = misplaced_elements.begin();
    int x = itr->first, xpos = itr->second;
    ++itr;
    int y = itr->first, ypos = itr->second;
    arr[xpos] = y;
    arr[ypos] = x;
    bool is_increasing = true;
    for (int i = 0; i < n; i++) {
      if (arr[i] != sorted[i]) {
        is_increasing = false;
        break;
      }
    }
    if (is_increasing == true) {
      cout << "YES";
    } else {
      cout << "NO";
    }
  } else {
    cout << "NO";
  }
  return 0;
}
