#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, pos = 0, x = 0, y = 0, flag = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; i++) {
    if (a[i] > a[i + 1]) {
      x = i;
      while (a[x] == a[x - 1] && x > 0) x--;
      break;
    }
  }
  for (int i = n - 1; i > 0; i--) {
    if (a[i] < a[i - 1]) {
      y = i;
      while (a[y] == a[y + 1] && y < n - 1) y++;
      break;
    }
  }
  swap(a[x], a[y]);
  for (int i = 0; i < n - 1; i++) {
    if (a[i] > a[i + 1]) {
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}
