#include <bits/stdc++.h>
using namespace std;
vector<int> final;
vector<int> visited;
void DFS(vector<vector<pair<int, bool> > >& graph, int start, int v) {
  visited[v] = true;
  for (int i = 0; i < graph[v].size(); i++) {
    int to = graph[v][i].first;
    if (visited[to]) continue;
    if (!graph[v][i].second) ++final[start];
    DFS(graph, start, to);
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> sorted(n), unsorted(n);
  for (int i = 0; i < n; i++) {
    cin >> unsorted[i];
    sorted[i] = unsorted[i];
  }
  stable_sort(sorted.begin(), sorted.end());
  int k = 0;
  for (int i = 0; i < n; i++)
    if (sorted[i] != unsorted[i]) ++k;
  if (k == 0 || k == 2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
