#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
long long int a[N], b[N];
int main() {
  long long int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  long long int ans = 0;
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) ans++;
  if (ans <= 2)
    cout << "YES";
  else
    cout << "NO";
}
