import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] list = new int[n];
		int[] newList = new int[n];
		int tmpNum;
		for(int i =0; i<n; i++) {
			tmpNum = Integer.parseInt(sc.next());
			list[i] = tmpNum;
			newList[i] = tmpNum;
		}
		Arrays.sort(newList);
		int tmp = list[0];
		int flg = 0;

		int first = 0;
		int firstIndex = 0;
		int last = 0;
		int lastIndex = 0;
		for(int i=1; i<n; i++) {

			if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			}

			if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			}
			tmp = list[i];
		}

		if(flg == 2) {
			list[firstIndex] = last;
			list[lastIndex] = first;
		}else if(flg==1){
			list[firstIndex] = list[firstIndex + 1];
			list[firstIndex + 1] = first;
		}
		int judge = 0;
		for(int i=0;i<n;i++) {
			if(list[i] != newList[i]) {
				judge = 1;
			}
		}

		if(judge==0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] list = new int[n];
		int[] newList = new int[n];
		int tmpNum;
		for(int i =0; i<n; i++) {
			tmpNum = Integer.parseInt(sc.next());
			list[i] = tmpNum;
			newList[i] = tmpNum;
		}
		Arrays.sort(newList);
		int tmp = list[0];
		int flg = 0;

		int first = 0;
		int firstIndex = 0;
		int last = 0;
		int lastIndex = 0;
		for(int i=1; i<n; i++) {

			if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			}

			if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			}
			tmp = list[i];
		}

		if(flg == 2) {
			list[firstIndex] = last;
			list[lastIndex] = first;
		}else if(flg==1){
			list[firstIndex] = list[firstIndex + 1];
			list[firstIndex + 1] = first;
		}
		int judge = 0;
		for(int i=0;i<n;i++) {
			if(list[i] != newList[i]) {
				judge = 1;
			}
		}

		if(judge==0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] list = new int[n];
		int[] newList = new int[n];
		int tmpNum;
		for(int i =0; i<n; i++) {
			tmpNum = Integer.parseInt(sc.next());
			list[i] = tmpNum;
			newList[i] = tmpNum;
		}
		Arrays.sort(newList);
		int tmp = list[0];
		int flg = 0;

		int first = 0;
		int firstIndex = 0;
		int last = 0;
		int lastIndex = 0;
		for(int i=1; i<n; i++) {

			if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			}

			if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			}
			tmp = list[i];
		}

		if(flg == 2) {
			list[firstIndex] = last;
			list[lastIndex] = first;
		}else if(flg==1){
			list[firstIndex] = list[firstIndex + 1];
			list[firstIndex + 1] = first;
		}
		int judge = 0;
		for(int i=0;i<n;i++) {
			if(list[i] != newList[i]) {
				judge = 1;
			}
		}

		if(judge==0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	} main {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] list = new int[n];
		int[] newList = new int[n];
		int tmpNum;
		for(int i =0; i<n; i++) {
			tmpNum = Integer.parseInt(sc.next());
			list[i] = tmpNum;
			newList[i] = tmpNum;
		}
		Arrays.sort(newList);
		int tmp = list[0];
		int flg = 0;

		int first = 0;
		int firstIndex = 0;
		int last = 0;
		int lastIndex = 0;
		for(int i=1; i<n; i++) {

			if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			}

			if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			}
			tmp = list[i];
		}

		if(flg == 2) {
			list[firstIndex] = last;
			list[lastIndex] = first;
		}else if(flg==1){
			list[firstIndex] = list[firstIndex + 1];
			list[firstIndex + 1] = first;
		}
		int judge = 0;
		for(int i=0;i<n;i++) {
			if(list[i] != newList[i]) {
				judge = 1;
			}
		}

		if(judge==0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] list = new int[n]; list new int[n] n int[] newList = new int[n]; newList new int[n] n int tmpNum; tmpNum for(int i =0; i<n; i++) {
			tmpNum = Integer.parseInt(sc.next());
			list[i] = tmpNum;
			newList[i] = tmpNum;
		} int i =0; int i =0; i 0 i<n i n i++ i++ i {
			tmpNum = Integer.parseInt(sc.next());
			list[i] = tmpNum;
			newList[i] = tmpNum;
		} {
			tmpNum = Integer.parseInt(sc.next());
			list[i] = tmpNum;
			newList[i] = tmpNum;
		} tmpNum = Integer.parseInt(sc.next()) tmpNum Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc list[i] = tmpNum list[i] list i tmpNum newList[i] = tmpNum newList[i] newList i tmpNum Arrays.sort(newList) Arrays.sort Arrays newList int tmp = list[0]; tmp list[0] list 0 int flg = 0; flg 0 int first = 0; first 0 int firstIndex = 0; firstIndex 0 int last = 0; last 0 int lastIndex = 0; lastIndex 0 for(int i=1; i<n; i++) {

			if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			}

			if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			}
			tmp = list[i];
		} int i=1; int i=1; i 1 i<n i n i++ i++ i {

			if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			}

			if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			}
			tmp = list[i];
		} {

			if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			}

			if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			}
			tmp = list[i];
		} if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			} flg == 1 && list[i] < tmp flg == 1 flg 1 list[i] < tmp list[i] list i tmp {
				last = list[i];
				lastIndex = i;
				flg = 2;
			} last = list[i] last list[i] list i lastIndex = i lastIndex i flg = 2 flg 2 if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			} flg == 0 && list[i] < tmp flg == 0 flg 0 list[i] < tmp list[i] list i tmp {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			} first = list[i-1] first list[i-1] list i-1 i 1 firstIndex = i-1 firstIndex i-1 i 1 flg = 1 flg 1 tmp = list[i] tmp list[i] list i if(flg == 2) {
			list[firstIndex] = last;
			list[lastIndex] = first;
		}else if(flg==1){
			list[firstIndex] = list[firstIndex + 1];
			list[firstIndex + 1] = first;
		} flg == 2 flg 2 {
			list[firstIndex] = last;
			list[lastIndex] = first;
		} list[firstIndex] = last list[firstIndex] list firstIndex last list[lastIndex] = first list[lastIndex] list lastIndex first if(flg==1){
			list[firstIndex] = list[firstIndex + 1];
			list[firstIndex + 1] = first;
		} flg==1 flg 1 {
			list[firstIndex] = list[firstIndex + 1];
			list[firstIndex + 1] = first;
		} list[firstIndex] = list[firstIndex + 1] list[firstIndex] list firstIndex list[firstIndex + 1] list firstIndex + 1 firstIndex 1 list[firstIndex + 1] = first list[firstIndex + 1] list firstIndex + 1 firstIndex 1 first int judge = 0; judge 0 for(int i=0;i<n;i++) {
			if(list[i] != newList[i]) {
				judge = 1;
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			if(list[i] != newList[i]) {
				judge = 1;
			}
		} {
			if(list[i] != newList[i]) {
				judge = 1;
			}
		} if(list[i] != newList[i]) {
				judge = 1;
			} list[i] != newList[i] list[i] list i newList[i] newList i {
				judge = 1;
			} judge = 1 judge 1 if(judge==0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		} judge==0 judge 0 {
			System.out.println("YES");
		} System.out.println("YES") System.out.println System.out System System.out "YES" {
			System.out.println("NO");
		} System.out.println("NO") System.out.println System.out System System.out "NO" String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] list = new int[n];
		int[] newList = new int[n];
		int tmpNum;
		for(int i =0; i<n; i++) {
			tmpNum = Integer.parseInt(sc.next());
			list[i] = tmpNum;
			newList[i] = tmpNum;
		}
		Arrays.sort(newList);
		int tmp = list[0];
		int flg = 0;

		int first = 0;
		int firstIndex = 0;
		int last = 0;
		int lastIndex = 0;
		for(int i=1; i<n; i++) {

			if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			}

			if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			}
			tmp = list[i];
		}

		if(flg == 2) {
			list[firstIndex] = last;
			list[lastIndex] = first;
		}else if(flg==1){
			list[firstIndex] = list[firstIndex + 1];
			list[firstIndex + 1] = first;
		}
		int judge = 0;
		for(int i=0;i<n;i++) {
			if(list[i] != newList[i]) {
				judge = 1;
			}
		}

		if(judge==0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] list = new int[n];
		int[] newList = new int[n];
		int tmpNum;
		for(int i =0; i<n; i++) {
			tmpNum = Integer.parseInt(sc.next());
			list[i] = tmpNum;
			newList[i] = tmpNum;
		}
		Arrays.sort(newList);
		int tmp = list[0];
		int flg = 0;

		int first = 0;
		int firstIndex = 0;
		int last = 0;
		int lastIndex = 0;
		for(int i=1; i<n; i++) {

			if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			}

			if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			}
			tmp = list[i];
		}

		if(flg == 2) {
			list[firstIndex] = last;
			list[lastIndex] = first;
		}else if(flg==1){
			list[firstIndex] = list[firstIndex + 1];
			list[firstIndex + 1] = first;
		}
		int judge = 0;
		for(int i=0;i<n;i++) {
			if(list[i] != newList[i]) {
				judge = 1;
			}
		}

		if(judge==0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] list = new int[n];
		int[] newList = new int[n];
		int tmpNum;
		for(int i =0; i<n; i++) {
			tmpNum = Integer.parseInt(sc.next());
			list[i] = tmpNum;
			newList[i] = tmpNum;
		}
		Arrays.sort(newList);
		int tmp = list[0];
		int flg = 0;

		int first = 0;
		int firstIndex = 0;
		int last = 0;
		int lastIndex = 0;
		for(int i=1; i<n; i++) {

			if(flg == 1 && list[i] < tmp) {
				last = list[i];
				lastIndex = i;
				flg = 2;
			}

			if(flg == 0 && list[i] < tmp) {
				first = list[i-1];
				firstIndex = i-1;
				flg = 1;
			}
			tmp = list[i];
		}

		if(flg == 2) {
			list[firstIndex] = last;
			list[lastIndex] = first;
		}else if(flg==1){
			list[firstIndex] = list[firstIndex + 1];
			list[firstIndex + 1] = first;
		}
		int judge = 0;
		for(int i=0;i<n;i++) {
			if(list[i] != newList[i]) {
				judge = 1;
			}
		}

		if(judge==0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}