#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
vector<long long> v(10);
long long p(long long x, long long n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return p((x * x) % M, n / 2);
  else
    return (x * p((x * x) % M, (n - 1) / 2)) % M;
}
long long check(long long i) {
  while (i > 0) {
    long long t = i % 10;
    if (v[t] != 0) return 1;
    i /= 10;
  }
  return 0;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  long long c = 0;
  vector<long long> temp;
  sort(b.begin(), b.end());
  for (long long i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      c++;
      temp.push_back(i);
    }
  }
  if (c == 0 || c == 2) {
    if (c == 2) {
      if (a[temp[0]] == b[temp[1]])
        cout << "YES";
      else
        cout << "NO";
      return 0;
    }
    cout << "YES";
    return 0;
  }
  cout << "NO";
}
