#include <iostream>
using namespace std;
auto main()->int
{
	int n;
	cin >> n;
	auto count = 0;
	for (auto i = 1; i <= n; ++i) {
		int p;
		cin >> p;
		if (p != i)
			++count;
	}
	cout << (count <= 2 ? "YES" : "NO") << endl;
}