#include <bits/stdc++.h>
using namespace std;
int ans, n, a[1000000], mx, b[1000000];
int main() {
	cin>>n;
	for (int i = 1; i <= n; i++) {
		cin>>a[i];
		if (a[i] != i) ans++;
	}
	if (ans <= 2) cout<<"YES";
	else cout<<"NO";
}
