import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int r = 0;
		for (int i = 1; i <= n; i++)
			if (in.nextInt() != i)
				r++;
		if (r <= 2)
			System.out.println("YES");
		else
			System.out.println("NO");
		in.close();
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int r = 0;
		for (int i = 1; i <= n; i++)
			if (in.nextInt() != i)
				r++;
		if (r <= 2)
			System.out.println("YES");
		else
			System.out.println("NO");
		in.close();
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int r = 0;
		for (int i = 1; i <= n; i++)
			if (in.nextInt() != i)
				r++;
		if (r <= 2)
			System.out.println("YES");
		else
			System.out.println("NO");
		in.close();
	} main {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int r = 0;
		for (int i = 1; i <= n; i++)
			if (in.nextInt() != i)
				r++;
		if (r <= 2)
			System.out.println("YES");
		else
			System.out.println("NO");
		in.close();
	} Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); in new Scanner(new BufferedReader(new InputStreamReader(System.in))) int n = in.nextInt(); n in.nextInt() in.nextInt in int r = 0; r 0 for (int i = 1; i <= n; i++)
			if (in.nextInt() != i)
				r++; int i = 1; int i = 1; i 1 i <= n i n i++ i++ i if (in.nextInt() != i)
				r++; if (in.nextInt() != i)
				r++; in.nextInt() != i in.nextInt() in.nextInt in i r++ r if (r <= 2)
			System.out.println("YES");
		else
			System.out.println("NO"); r <= 2 r 2 System.out.println("YES") System.out.println System.out System System.out "YES" System.out.println("NO") System.out.println System.out System System.out "NO" in.close() in.close in String[] args args public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int r = 0;
		for (int i = 1; i <= n; i++)
			if (in.nextInt() != i)
				r++;
		if (r <= 2)
			System.out.println("YES");
		else
			System.out.println("NO");
		in.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int r = 0;
		for (int i = 1; i <= n; i++)
			if (in.nextInt() != i)
				r++;
		if (r <= 2)
			System.out.println("YES");
		else
			System.out.println("NO");
		in.close();
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int r = 0;
		for (int i = 1; i <= n; i++)
			if (in.nextInt() != i)
				r++;
		if (r <= 2)
			System.out.println("YES");
		else
			System.out.println("NO");
		in.close();
	}
}
