import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int p[] = new int[N];
    boolean out = false;
    for (int i=0; i<N; i++) {
      p[i] = sc.nextInt();
    }

    out = hantei(p, N);

    if(!out){
      loop:for(int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
          int temp = 0;
          temp = p[i];
          p[i] = p[j];
          p[j] = temp;
          if(hantei(p, N)){
            out = true;
            break loop;
          } else {
            temp = p[j];
            p[j] = p[i];
            p[i] = temp;
          }
        }
      }
    }

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

  public static boolean hantei(int p[], int N){
    boolean out = false;
    for (int i=0; i<N-1; i++) {
      if(p[i] > p[i+1]){
        break;
      }
      if(i == N-2){
        out = true;
      }
    }
    return out;
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int p[] = new int[N];
    boolean out = false;
    for (int i=0; i<N; i++) {
      p[i] = sc.nextInt();
    }

    out = hantei(p, N);

    if(!out){
      loop:for(int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
          int temp = 0;
          temp = p[i];
          p[i] = p[j];
          p[j] = temp;
          if(hantei(p, N)){
            out = true;
            break loop;
          } else {
            temp = p[j];
            p[j] = p[i];
            p[i] = temp;
          }
        }
      }
    }

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

  public static boolean hantei(int p[], int N){
    boolean out = false;
    for (int i=0; i<N-1; i++) {
      if(p[i] > p[i+1]){
        break;
      }
      if(i == N-2){
        out = true;
      }
    }
    return out;
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int p[] = new int[N];
    boolean out = false;
    for (int i=0; i<N; i++) {
      p[i] = sc.nextInt();
    }

    out = hantei(p, N);

    if(!out){
      loop:for(int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
          int temp = 0;
          temp = p[i];
          p[i] = p[j];
          p[j] = temp;
          if(hantei(p, N)){
            out = true;
            break loop;
          } else {
            temp = p[j];
            p[j] = p[i];
            p[i] = temp;
          }
        }
      }
    }

    if(out){
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int p[] = new int[N];
    boolean out = false;
    for (int i=0; i<N; i++) {
      p[i] = sc.nextInt();
    }

    out = hantei(p, N);

    if(!out){
      loop:for(int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
          int temp = 0;
          temp = p[i];
          p[i] = p[j];
          p[j] = temp;
          if(hantei(p, N)){
            out = true;
            break loop;
          } else {
            temp = p[j];
            p[j] = p[i];
            p[i] = temp;
          }
        }
      }
    }

    if(out){
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int p[] = new int[N]; p new int[N] N boolean out = false; out false for (int i=0; i<N; i++) {
      p[i] = sc.nextInt();
    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
      p[i] = sc.nextInt();
    } {
      p[i] = sc.nextInt();
    } p[i] = sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc out = hantei(p, N) out hantei(p, N) hantei p N if(!out){
      loop:for(int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
          int temp = 0;
          temp = p[i];
          p[i] = p[j];
          p[j] = temp;
          if(hantei(p, N)){
            out = true;
            break loop;
          } else {
            temp = p[j];
            p[j] = p[i];
            p[i] = temp;
          }
        }
      }
    } !out out {
      loop:for(int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
          int temp = 0;
          temp = p[i];
          p[i] = p[j];
          p[j] = temp;
          if(hantei(p, N)){
            out = true;
            break loop;
          } else {
            temp = p[j];
            p[j] = p[i];
            p[i] = temp;
          }
        }
      }
    } if(out){
      System.out.println("YES");
    } else {
      System.out.println("NO");
    } out {
      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 static boolean hantei(int p[], int N){
    boolean out = false;
    for (int i=0; i<N-1; i++) {
      if(p[i] > p[i+1]){
        break;
      }
      if(i == N-2){
        out = true;
      }
    }
    return out;
  } hantei {
    boolean out = false;
    for (int i=0; i<N-1; i++) {
      if(p[i] > p[i+1]){
        break;
      }
      if(i == N-2){
        out = true;
      }
    }
    return out;
  } boolean out = false; out false for (int i=0; i<N-1; i++) {
      if(p[i] > p[i+1]){
        break;
      }
      if(i == N-2){
        out = true;
      }
    } int i=0; int i=0; i 0 i<N-1 i N-1 N 1 i++ i++ i {
      if(p[i] > p[i+1]){
        break;
      }
      if(i == N-2){
        out = true;
      }
    } {
      if(p[i] > p[i+1]){
        break;
      }
      if(i == N-2){
        out = true;
      }
    } if(p[i] > p[i+1]){
        break;
      } p[i] > p[i+1] p[i] p i p[i+1] p i+1 i 1 {
        break;
      } break; if(i == N-2){
        out = true;
      } i == N-2 i N-2 N 2 {
        out = true;
      } out = true out true return out; out int p[] p int N N public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int p[] = new int[N];
    boolean out = false;
    for (int i=0; i<N; i++) {
      p[i] = sc.nextInt();
    }

    out = hantei(p, N);

    if(!out){
      loop:for(int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
          int temp = 0;
          temp = p[i];
          p[i] = p[j];
          p[j] = temp;
          if(hantei(p, N)){
            out = true;
            break loop;
          } else {
            temp = p[j];
            p[j] = p[i];
            p[i] = temp;
          }
        }
      }
    }

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

  public static boolean hantei(int p[], int N){
    boolean out = false;
    for (int i=0; i<N-1; i++) {
      if(p[i] > p[i+1]){
        break;
      }
      if(i == N-2){
        out = true;
      }
    }
    return out;
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int p[] = new int[N];
    boolean out = false;
    for (int i=0; i<N; i++) {
      p[i] = sc.nextInt();
    }

    out = hantei(p, N);

    if(!out){
      loop:for(int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
          int temp = 0;
          temp = p[i];
          p[i] = p[j];
          p[j] = temp;
          if(hantei(p, N)){
            out = true;
            break loop;
          } else {
            temp = p[j];
            p[j] = p[i];
            p[i] = temp;
          }
        }
      }
    }

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

  public static boolean hantei(int p[], int N){
    boolean out = false;
    for (int i=0; i<N-1; i++) {
      if(p[i] > p[i+1]){
        break;
      }
      if(i == N-2){
        out = true;
      }
    }
    return out;
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int p[] = new int[N];
    boolean out = false;
    for (int i=0; i<N; i++) {
      p[i] = sc.nextInt();
    }

    out = hantei(p, N);

    if(!out){
      loop:for(int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
          int temp = 0;
          temp = p[i];
          p[i] = p[j];
          p[j] = temp;
          if(hantei(p, N)){
            out = true;
            break loop;
          } else {
            temp = p[j];
            p[j] = p[i];
            p[i] = temp;
          }
        }
      }
    }

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

  public static boolean hantei(int p[], int N){
    boolean out = false;
    for (int i=0; i<N-1; i++) {
      if(p[i] > p[i+1]){
        break;
      }
      if(i == N-2){
        out = true;
      }
    }
    return out;
  }
}