#include <bits/stdc++.h>
using namespace std;
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
int main() {
  file();
  fast();
  int n;
  cin >> n;
  vector<int> a(n), s;
  for (int i = 0; i < n; i++) cin >> a[i];
  s = a;
  sort(s.begin(), s.end());
  vector<int> v;
  for (int i = 0; i < n && v.size() < 5; i++)
    if (a[i] != s[i]) v.push_back(i);
  if (v.size() == 0) {
    cout << "YES";
    return 0;
  }
  if (v.size() != 2) {
    cout << "NO";
    return 0;
  }
  if (a[v[0]] == s[v[1]] && a[v[1]] == s[v[0]])
    cout << "YES";
  else
    cout << "NO";
}
