#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int ind1=0;
  int ar[n];
  for(int i=0;i<n;++i)
  {cin>>ar[i];if(ar[i]!=i+1){ind1++;}}
  if(ind1<=2){cout<<"YES";return 0;}
  cout<<"NO";
}
  
