/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

import java.util.*;
import java.util.Collections; // sorting use
import java.io.*;
import static java.lang.System.*;

public class Main{
	public static void main(String[] args){
		int n;
		int cnt = 0;
		ArrayList<Integer> p = new ArrayList<Integer>(53);
		Scanner sc = new Scanner(System.in);

		p.add(0);
		n = sc.nextInt();
		for (int i = 1; i <= n; ++i) {
			p.add(sc.nextInt());
			if(p.get(i) != i)	++cnt;
		}
		if(cnt >= 3)	out.println("NO");
		else out.println("YES");
	}
} import java.util.*; util.* java import java.util.Collections; // sorting use Collections java.util import java.io.*; io.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main{
	public static void main(String[] args){
		int n;
		int cnt = 0;
		ArrayList<Integer> p = new ArrayList<Integer>(53);
		Scanner sc = new Scanner(System.in);

		p.add(0);
		n = sc.nextInt();
		for (int i = 1; i <= n; ++i) {
			p.add(sc.nextInt());
			if(p.get(i) != i)	++cnt;
		}
		if(cnt >= 3)	out.println("NO");
		else out.println("YES");
	}
} Main public static void main(String[] args){
		int n;
		int cnt = 0;
		ArrayList<Integer> p = new ArrayList<Integer>(53);
		Scanner sc = new Scanner(System.in);

		p.add(0);
		n = sc.nextInt();
		for (int i = 1; i <= n; ++i) {
			p.add(sc.nextInt());
			if(p.get(i) != i)	++cnt;
		}
		if(cnt >= 3)	out.println("NO");
		else out.println("YES");
	} main {
		int n;
		int cnt = 0;
		ArrayList<Integer> p = new ArrayList<Integer>(53);
		Scanner sc = new Scanner(System.in);

		p.add(0);
		n = sc.nextInt();
		for (int i = 1; i <= n; ++i) {
			p.add(sc.nextInt());
			if(p.get(i) != i)	++cnt;
		}
		if(cnt >= 3)	out.println("NO");
		else out.println("YES");
	} int n; n int cnt = 0; cnt 0 ArrayList<Integer> p = new ArrayList<Integer>(53); p new ArrayList<Integer>(53) Scanner sc = new Scanner(System.in); sc new Scanner(System.in) p.add(0) p.add p 0 n = sc.nextInt() n sc.nextInt() sc.nextInt sc for (int i = 1; i <= n; ++i) {
			p.add(sc.nextInt());
			if(p.get(i) != i)	++cnt;
		} int i = 1; int i = 1; i 1 i <= n i n ++i ++i i {
			p.add(sc.nextInt());
			if(p.get(i) != i)	++cnt;
		} {
			p.add(sc.nextInt());
			if(p.get(i) != i)	++cnt;
		} p.add(sc.nextInt()) p.add p sc.nextInt() sc.nextInt sc if(p.get(i) != i)	++cnt; p.get(i) != i p.get(i) p.get p i i ++cnt cnt if(cnt >= 3)	out.println("NO");
		else out.println("YES"); cnt >= 3 cnt 3 out.println("NO") out.println out "NO" out.println("YES") out.println out "YES" String[] args args public class Main{
	public static void main(String[] args){
		int n;
		int cnt = 0;
		ArrayList<Integer> p = new ArrayList<Integer>(53);
		Scanner sc = new Scanner(System.in);

		p.add(0);
		n = sc.nextInt();
		for (int i = 1; i <= n; ++i) {
			p.add(sc.nextInt());
			if(p.get(i) != i)	++cnt;
		}
		if(cnt >= 3)	out.println("NO");
		else out.println("YES");
	}
} public class Main{
	public static void main(String[] args){
		int n;
		int cnt = 0;
		ArrayList<Integer> p = new ArrayList<Integer>(53);
		Scanner sc = new Scanner(System.in);

		p.add(0);
		n = sc.nextInt();
		for (int i = 1; i <= n; ++i) {
			p.add(sc.nextInt());
			if(p.get(i) != i)	++cnt;
		}
		if(cnt >= 3)	out.println("NO");
		else out.println("YES");
	}
} Main
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

import java.util.*;
import java.util.Collections; // sorting use
import java.io.*;
import static java.lang.System.*;

public class Main{
	public static void main(String[] args){
		int n;
		int cnt = 0;
		ArrayList<Integer> p = new ArrayList<Integer>(53);
		Scanner sc = new Scanner(System.in);

		p.add(0);
		n = sc.nextInt();
		for (int i = 1; i <= n; ++i) {
			p.add(sc.nextInt());
			if(p.get(i) != i)	++cnt;
		}
		if(cnt >= 3)	out.println("NO");
		else out.println("YES");
	}
}
