#include<iostream>
using namespace std;
#define ll long long int
int main()
{
  ll n;
  cin>>n;
  ll i,a,cnt=0;
  for(i=1;i<=n;i++)
  {
  	cin>>a;
  	if(a!=i)
  		cnt++;
  }
  if(cnt>2)
	return cout<<"NO",0;
	cout<<"YES";
}