#include <bits/stdc++.h>
using namespace std;
ifstream Cin("input.txt");
ofstream Cout("output.txt");
int main() {
  long long n, x, i, num = 0, m[100001], m1[100001];
  m[0] = m1[0] = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> m[i];
    m1[i] = m[i];
  }
  sort(m, m + n + 1);
  for (i = 1; i <= n; i++) {
    if (m[i] != m1[i]) {
      num++;
    }
  }
  cout << (num <= 2 ? "YES" : "NO");
}
