unittest
{
	assert( [ "5", "5 2 3 4 1" ].parse.expand.solve == "YES" );
	assert( [ "5", "2 4 3 5 1" ].parse.expand.solve == "NO" );
	assert( [ "7", "1 2 3 4 5 6 7" ].parse.expand.solve == "YES" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto ps = input.front.split.to!( long[] );
	return tuple( ps );
}

auto solve( long[] ps )
{
	auto r = 0L;
	foreach( i, p; ps )
	{
		r += ( i + 1 != p );
	}
	return ( r <= 2 ) ? "YES" : "NO";
}
