#include <iostream>
#include <string>
using namespace std;
int main()
{
	int q,w,e=0,i,j;
	cin>>q;
	for(i=1;i<=q;i++)
	{
		cin>>w;
		if(w!=i)
		e++;
	}
	if(e>2)
	cout<<"NO";
	else
	cout<<"YES";
	
	
	return 0;
}