#include <stdio.h>

int main()
{
	int N; register int i, nwrong=0;
	scanf("%d", &N);
	inf p[N];
	for (i = 0; i < N; i++) {
		scanf("%d", &p[i]);
		if (p[i] != i+1) nwrong++;
	}
	if (nwrong > 2) puts("NO");
	else puts("YES");
	return 0;
}