import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int[] arr=new int[n];
		int[] temp=new int[arr.length];
		int tem,c=0;;
		for(int i=0;i<arr.length;i++)
		{
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		}
		input.close();
		Arrays.sort(temp);	
          
		for(int j=0;j<arr.length;j++)
		{
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   }

		if(c<3) 
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}	
		System.exit(0);
		
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int[] arr=new int[n];
		int[] temp=new int[arr.length];
		int tem,c=0;;
		for(int i=0;i<arr.length;i++)
		{
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		}
		input.close();
		Arrays.sort(temp);	
          
		for(int j=0;j<arr.length;j++)
		{
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   }

		if(c<3) 
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}	
		System.exit(0);
		
	}
} Main public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int[] arr=new int[n];
		int[] temp=new int[arr.length];
		int tem,c=0;;
		for(int i=0;i<arr.length;i++)
		{
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		}
		input.close();
		Arrays.sort(temp);	
          
		for(int j=0;j<arr.length;j++)
		{
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   }

		if(c<3) 
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}	
		System.exit(0);
		
	} main {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int[] arr=new int[n];
		int[] temp=new int[arr.length];
		int tem,c=0;;
		for(int i=0;i<arr.length;i++)
		{
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		}
		input.close();
		Arrays.sort(temp);	
          
		for(int j=0;j<arr.length;j++)
		{
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   }

		if(c<3) 
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}	
		System.exit(0);
		
	} Scanner input =new Scanner(System.in); input new Scanner(System.in) int n=input.nextInt(); n input.nextInt() input.nextInt input int[] arr=new int[n]; arr new int[n] n int[] temp=new int[arr.length]; temp new int[arr.length] arr.length arr arr.length int tem tem c=0; c 0 for(int i=0;i<arr.length;i++)
		{
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		} int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		} {
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		} arr[i]=input.nextInt() arr[i] arr i input.nextInt() input.nextInt input temp[i]=arr[i] temp[i] temp i arr[i] arr i input.close() input.close input Arrays.sort(temp) Arrays.sort Arrays temp for(int j=0;j<arr.length;j++)
		{
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   } int j=0; int j=0; j 0 j<arr.length j arr.length arr arr.length j++ j++ j {
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   } {
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   } if(arr[j] != temp[j]) 
			{
				c++;
			} arr[j] != temp[j] arr[j] arr j temp[j] temp j {
				c++;
			} c++ c if(c<3) 
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		} c<3 c 3 {
			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" System.exit(0) System.exit System 0 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int[] arr=new int[n];
		int[] temp=new int[arr.length];
		int tem,c=0;;
		for(int i=0;i<arr.length;i++)
		{
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		}
		input.close();
		Arrays.sort(temp);	
          
		for(int j=0;j<arr.length;j++)
		{
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   }

		if(c<3) 
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}	
		System.exit(0);
		
	}
} public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int[] arr=new int[n];
		int[] temp=new int[arr.length];
		int tem,c=0;;
		for(int i=0;i<arr.length;i++)
		{
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		}
		input.close();
		Arrays.sort(temp);	
          
		for(int j=0;j<arr.length;j++)
		{
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   }

		if(c<3) 
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}	
		System.exit(0);
		
	}
} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int[] arr=new int[n];
		int[] temp=new int[arr.length];
		int tem,c=0;;
		for(int i=0;i<arr.length;i++)
		{
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		}
		input.close();
		Arrays.sort(temp);	
          
		for(int j=0;j<arr.length;j++)
		{
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   }

		if(c<3) 
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}	
		System.exit(0);
		
	}
}
