import java.util.Scanner;
import java.util.InputMismatchException;

class Main {
   public static void main(String args[]) {
      int N=0;
      int[] p;
      Scanner scanner = new Scanner(System.in);
      N = scanner.nextInt();
      p = new int[N];
      for (int i=0; i<N; i++) {
         p[i] = scanner.nextInt();
      }
      scanner.close();
      int flag = 0;
      for (int k = 0; k<N-1; k++) {
         for (int i=k+1; i<N; i++) {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         }
      }
      if (flag == 0) {
         System.out.println("YES");
      } else {
         int flag2 = 0;
         int flag3 = 0;
         for (int i= 0; i<N-1; i++) {
            for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            }
            if (flag3 == 1) {
               break;
            }
         }

         if (flag3 == 0) {
            System.out.println("NO");
         }

      }

   }
} import java.util.Scanner; Scanner java.util import java.util.InputMismatchException; InputMismatchException java.util class Main {
   public static void main(String args[]) {
      int N=0;
      int[] p;
      Scanner scanner = new Scanner(System.in);
      N = scanner.nextInt();
      p = new int[N];
      for (int i=0; i<N; i++) {
         p[i] = scanner.nextInt();
      }
      scanner.close();
      int flag = 0;
      for (int k = 0; k<N-1; k++) {
         for (int i=k+1; i<N; i++) {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         }
      }
      if (flag == 0) {
         System.out.println("YES");
      } else {
         int flag2 = 0;
         int flag3 = 0;
         for (int i= 0; i<N-1; i++) {
            for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            }
            if (flag3 == 1) {
               break;
            }
         }

         if (flag3 == 0) {
            System.out.println("NO");
         }

      }

   }
} Main public static void main(String args[]) {
      int N=0;
      int[] p;
      Scanner scanner = new Scanner(System.in);
      N = scanner.nextInt();
      p = new int[N];
      for (int i=0; i<N; i++) {
         p[i] = scanner.nextInt();
      }
      scanner.close();
      int flag = 0;
      for (int k = 0; k<N-1; k++) {
         for (int i=k+1; i<N; i++) {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         }
      }
      if (flag == 0) {
         System.out.println("YES");
      } else {
         int flag2 = 0;
         int flag3 = 0;
         for (int i= 0; i<N-1; i++) {
            for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            }
            if (flag3 == 1) {
               break;
            }
         }

         if (flag3 == 0) {
            System.out.println("NO");
         }

      }

   } main {
      int N=0;
      int[] p;
      Scanner scanner = new Scanner(System.in);
      N = scanner.nextInt();
      p = new int[N];
      for (int i=0; i<N; i++) {
         p[i] = scanner.nextInt();
      }
      scanner.close();
      int flag = 0;
      for (int k = 0; k<N-1; k++) {
         for (int i=k+1; i<N; i++) {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         }
      }
      if (flag == 0) {
         System.out.println("YES");
      } else {
         int flag2 = 0;
         int flag3 = 0;
         for (int i= 0; i<N-1; i++) {
            for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            }
            if (flag3 == 1) {
               break;
            }
         }

         if (flag3 == 0) {
            System.out.println("NO");
         }

      }

   } int N=0; N 0 int[] p; p Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) N = scanner.nextInt() N scanner.nextInt() scanner.nextInt scanner p = new int[N] p new int[N] N for (int i=0; i<N; i++) {
         p[i] = scanner.nextInt();
      } int i=0; int i=0; i 0 i<N i N i++ i++ i {
         p[i] = scanner.nextInt();
      } {
         p[i] = scanner.nextInt();
      } p[i] = scanner.nextInt() p[i] p i scanner.nextInt() scanner.nextInt scanner scanner.close() scanner.close scanner int flag = 0; flag 0 for (int k = 0; k<N-1; k++) {
         for (int i=k+1; i<N; i++) {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         }
      } int k = 0; int k = 0; k 0 k<N-1 k N-1 N 1 k++ k++ k {
         for (int i=k+1; i<N; i++) {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         }
      } {
         for (int i=k+1; i<N; i++) {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         }
      } for (int i=k+1; i<N; i++) {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         } int i=k+1; int i=k+1; i k+1 k 1 i<N i N i++ i++ i {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         } {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         } if (p[i] < p[k]) {
               flag = 1;
               break;
            } p[i] < p[k] p[i] p i p[k] p k {
               flag = 1;
               break;
            } flag = 1 flag 1 break; if (flag == 0) {
         System.out.println("YES");
      } else {
         int flag2 = 0;
         int flag3 = 0;
         for (int i= 0; i<N-1; i++) {
            for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            }
            if (flag3 == 1) {
               break;
            }
         }

         if (flag3 == 0) {
            System.out.println("NO");
         }

      } flag == 0 flag 0 {
         System.out.println("YES");
      } System.out.println("YES") System.out.println System.out System System.out "YES" {
         int flag2 = 0;
         int flag3 = 0;
         for (int i= 0; i<N-1; i++) {
            for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            }
            if (flag3 == 1) {
               break;
            }
         }

         if (flag3 == 0) {
            System.out.println("NO");
         }

      } int flag2 = 0; flag2 0 int flag3 = 0; flag3 0 for (int i= 0; i<N-1; i++) {
            for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            }
            if (flag3 == 1) {
               break;
            }
         } int i= 0; int i= 0; i 0 i<N-1 i N-1 N 1 i++ i++ i {
            for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            }
            if (flag3 == 1) {
               break;
            }
         } {
            for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            }
            if (flag3 == 1) {
               break;
            }
         } for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            } int j=i+1; int j=i+1; j i+1 i 1 j<N j N j++ j++ j {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            } {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            } int tmp = p[i]; tmp p[i] p i p[i] = p[j] p[i] p i p[j] p j p[j] = tmp p[j] p j tmp for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               } int k = 0; int k = 0; k 0 k<N-1 k N-1 N 1 k++ k++ k {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               } {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               } for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  } int l=k+1; int l=k+1; l k+1 k 1 l<N l N l++ l++ l {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  } {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  } if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     } p[l] < p[k] p[l] p l p[k] p k {
                        flag2 = 1;
                        break;
                     } flag2 = 1 flag2 1 break; if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               } flag2 == 0 flag2 0 {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               } System.out.println("YES") System.out.println System.out System System.out "YES" flag3 = 1 flag3 1 break; p[j] = p[i] p[j] p j p[i] p i p[i] = tmp p[i] p i tmp flag2 = 0 flag2 0 if (flag3 == 1) {
               break;
            } flag3 == 1 flag3 1 {
               break;
            } break; if (flag3 == 0) {
            System.out.println("NO");
         } flag3 == 0 flag3 0 {
            System.out.println("NO");
         } System.out.println("NO") System.out.println System.out System System.out "NO" String args[] args
import java.util.Scanner;
import java.util.InputMismatchException;

class Main {
   public static void main(String args[]) {
      int N=0;
      int[] p;
      Scanner scanner = new Scanner(System.in);
      N = scanner.nextInt();
      p = new int[N];
      for (int i=0; i<N; i++) {
         p[i] = scanner.nextInt();
      }
      scanner.close();
      int flag = 0;
      for (int k = 0; k<N-1; k++) {
         for (int i=k+1; i<N; i++) {
            if (p[i] < p[k]) {
               flag = 1;
               break;
            }
         }
      }
      if (flag == 0) {
         System.out.println("YES");
      } else {
         int flag2 = 0;
         int flag3 = 0;
         for (int i= 0; i<N-1; i++) {
            for (int j=i+1; j<N; j++) {

               int tmp = p[i];
               p[i] = p[j];
               p[j] = tmp;
               for (int k = 0; k<N-1; k++) {
                  for (int l=k+1; l<N; l++) {
                     if (p[l] < p[k]) {
                        flag2 = 1;
                        break;
                     }
                  }
               }
               // for (int k = 0; k<N; k++) {
               //    System.out.println(p[k]);
               // }
               // System.out.println();
               if (flag2 == 0) {
                  System.out.println("YES");
                  flag3 = 1;
                  break;
               }
               p[j] = p[i];
               p[i] = tmp;
               flag2 = 0;
            }
            if (flag3 == 1) {
               break;
            }
         }

         if (flag3 == 0) {
            System.out.println("NO");
         }

      }

   }
}
