#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n, x, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> x;
    cnt += x == i + 1;
  }
  cout << (cnt >= n - 2 ? "YES" : "NO") << endl;
}
