/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         st = new StringTokenizer(infile.readLine());
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //brute force
         if(sort(arr))
         {
            System.out.println("YES");
            return;
         }
         for(int a=0; a < N; a++)
            for(int b=a+1; b < N; b++)
            {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            }
         System.out.println("NO");
      }
      public static boolean sort(int[] arr)
      {
         for(int i=0; i < arr.length; i++)
            if(arr[i] != i+1)
               return false;
         return true;
      }
   } import java.util.*; util.* java import java.io.*; io.* java public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         st = new StringTokenizer(infile.readLine());
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //brute force
         if(sort(arr))
         {
            System.out.println("YES");
            return;
         }
         for(int a=0; a < N; a++)
            for(int b=a+1; b < N; b++)
            {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            }
         System.out.println("NO");
      }
      public static boolean sort(int[] arr)
      {
         for(int i=0; i < arr.length; i++)
            if(arr[i] != i+1)
               return false;
         return true;
      }
   } Main public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         st = new StringTokenizer(infile.readLine());
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //brute force
         if(sort(arr))
         {
            System.out.println("YES");
            return;
         }
         for(int a=0; a < N; a++)
            for(int b=a+1; b < N; b++)
            {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            }
         System.out.println("NO");
      } main {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         st = new StringTokenizer(infile.readLine());
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //brute force
         if(sort(arr))
         {
            System.out.println("YES");
            return;
         }
         for(int a=0; a < N; a++)
            for(int b=a+1; b < N; b++)
            {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            }
         System.out.println("NO");
      } BufferedReader infile = new BufferedReader(new InputStreamReader(System.in)); infile new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st = new StringTokenizer(infile.readLine()); st new StringTokenizer(infile.readLine()) int N = Integer.parseInt(st.nextToken()); N Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st st = new StringTokenizer(infile.readLine()) st new StringTokenizer(infile.readLine()) int[] arr = new int[N]; arr new int[N] N for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken()); int i=0; int i=0; i 0 i < N i N i++ i++ i arr[i] = Integer.parseInt(st.nextToken()); arr[i] = Integer.parseInt(st.nextToken()) arr[i] arr i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st if(sort(arr))
         {
            System.out.println("YES");
            return;
         } sort(arr) sort arr {
            System.out.println("YES");
            return;
         } System.out.println("YES") System.out.println System.out System System.out "YES" return; for(int a=0; a < N; a++)
            for(int b=a+1; b < N; b++)
            {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            } int a=0; int a=0; a 0 a < N a N a++ a++ a for(int b=a+1; b < N; b++)
            {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            } for(int b=a+1; b < N; b++)
            {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            } int b=a+1; int b=a+1; b a+1 a 1 b < N b N b++ b++ b {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            } {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            } int[] temp = new int[N]; temp new int[N] N for(int i=0; i < N; i++)
                  temp[i] = arr[i]; int i=0; int i=0; i 0 i < N i N i++ i++ i temp[i] = arr[i]; temp[i] = arr[i] temp[i] temp i arr[i] arr i temp[a] = arr[b] temp[a] temp a arr[b] arr b temp[b] = arr[a] temp[b] temp b arr[a] arr a if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               } sort(temp) sort temp {
                  System.out.println("YES");
                  return;
               } System.out.println("YES") System.out.println System.out System System.out "YES" return; System.out.println("NO") System.out.println System.out System System.out "NO" String args[] args public static boolean sort(int[] arr)
      {
         for(int i=0; i < arr.length; i++)
            if(arr[i] != i+1)
               return false;
         return true;
      } sort {
         for(int i=0; i < arr.length; i++)
            if(arr[i] != i+1)
               return false;
         return true;
      } for(int i=0; i < arr.length; i++)
            if(arr[i] != i+1)
               return false; int i=0; int i=0; i 0 i < arr.length i arr.length arr arr.length i++ i++ i if(arr[i] != i+1)
               return false; if(arr[i] != i+1)
               return false; arr[i] != i+1 arr[i] arr i i+1 i 1 return false; false return true; true int[] arr arr public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         st = new StringTokenizer(infile.readLine());
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //brute force
         if(sort(arr))
         {
            System.out.println("YES");
            return;
         }
         for(int a=0; a < N; a++)
            for(int b=a+1; b < N; b++)
            {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            }
         System.out.println("NO");
      }
      public static boolean sort(int[] arr)
      {
         for(int i=0; i < arr.length; i++)
            if(arr[i] != i+1)
               return false;
         return true;
      }
   } public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         st = new StringTokenizer(infile.readLine());
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //brute force
         if(sort(arr))
         {
            System.out.println("YES");
            return;
         }
         for(int a=0; a < N; a++)
            for(int b=a+1; b < N; b++)
            {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            }
         System.out.println("NO");
      }
      public static boolean sort(int[] arr)
      {
         for(int i=0; i < arr.length; i++)
            if(arr[i] != i+1)
               return false;
         return true;
      }
   } Main
/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         st = new StringTokenizer(infile.readLine());
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //brute force
         if(sort(arr))
         {
            System.out.println("YES");
            return;
         }
         for(int a=0; a < N; a++)
            for(int b=a+1; b < N; b++)
            {
               int[] temp = new int[N];
               for(int i=0; i < N; i++)
                  temp[i] = arr[i];
               temp[a] = arr[b];
               temp[b] = arr[a];
               if(sort(temp))
               {
                  System.out.println("YES");
                  return;
               }
            }
         System.out.println("NO");
      }
      public static boolean sort(int[] arr)
      {
         for(int i=0; i < arr.length; i++)
            if(arr[i] != i+1)
               return false;
         return true;
      }
   }