import java.util.*;

public class Main {
  public static void main(String[] args) {
    int N;
    int[] p;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      p = new int[N];
      for(int k = 0; k < N; k++) {
        p[k] = sc.nextInt();
      }
    }
    if ( isOk(p) ) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }
  }
  
  private static boolean isOk(int[] p) {
    int n = p.length;
    if ( isAscending(p) ) {
      return true;
    }
    else {
      for(int i = 0; i < n - 1; i++) {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      }
    }
    return false;
  }
  
  private static boolean isAscending(int[] p) {
    int n = p.length;
    if ( n < 2 ) {
      return true;
    }
    for(int i = 0; i < n - 1; i++ ) {
      int pi = p[i];
      for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      }
    }
    return true;
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    int N;
    int[] p;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      p = new int[N];
      for(int k = 0; k < N; k++) {
        p[k] = sc.nextInt();
      }
    }
    if ( isOk(p) ) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }
  }
  
  private static boolean isOk(int[] p) {
    int n = p.length;
    if ( isAscending(p) ) {
      return true;
    }
    else {
      for(int i = 0; i < n - 1; i++) {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      }
    }
    return false;
  }
  
  private static boolean isAscending(int[] p) {
    int n = p.length;
    if ( n < 2 ) {
      return true;
    }
    for(int i = 0; i < n - 1; i++ ) {
      int pi = p[i];
      for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      }
    }
    return true;
  }
} Main public static void main(String[] args) {
    int N;
    int[] p;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      p = new int[N];
      for(int k = 0; k < N; k++) {
        p[k] = sc.nextInt();
      }
    }
    if ( isOk(p) ) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }
  } main {
    int N;
    int[] p;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      p = new int[N];
      for(int k = 0; k < N; k++) {
        p[k] = sc.nextInt();
      }
    }
    if ( isOk(p) ) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }
  } int N; N int[] p; p try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      p = new int[N];
      for(int k = 0; k < N; k++) {
        p[k] = sc.nextInt();
      }
    } {
      N = sc.nextInt();
      p = new int[N];
      for(int k = 0; k < N; k++) {
        p[k] = sc.nextInt();
      }
    } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) N = sc.nextInt() N sc.nextInt() sc.nextInt sc p = new int[N] p new int[N] N for(int k = 0; k < N; k++) {
        p[k] = sc.nextInt();
      } int k = 0; int k = 0; k 0 k < N k N k++ k++ k {
        p[k] = sc.nextInt();
      } {
        p[k] = sc.nextInt();
      } p[k] = sc.nextInt() p[k] p k sc.nextInt() sc.nextInt sc if ( isOk(p) ) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    } isOk(p) isOk p {
      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 private static boolean isOk(int[] p) {
    int n = p.length;
    if ( isAscending(p) ) {
      return true;
    }
    else {
      for(int i = 0; i < n - 1; i++) {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      }
    }
    return false;
  } isOk {
    int n = p.length;
    if ( isAscending(p) ) {
      return true;
    }
    else {
      for(int i = 0; i < n - 1; i++) {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      }
    }
    return false;
  } int n = p.length; n p.length p p.length if ( isAscending(p) ) {
      return true;
    }
    else {
      for(int i = 0; i < n - 1; i++) {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      }
    } isAscending(p) isAscending p {
      return true;
    } return true; true {
      for(int i = 0; i < n - 1; i++) {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      }
    } for(int i = 0; i < n - 1; i++) {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      } {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      } int pi = p[i]; pi p[i] p i for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        } int j = i+1; int j = i+1; j i+1 i 1 j < n j n j++ j++ j {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        } {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        } int pj = p[j]; pj p[j] p j int[] p_result = new int[n]; p_result new int[n] n for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          } int k = 0; int k = 0; k 0 k < n k n k++ k++ k {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          } {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          } if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            } k == i k i {
              p_result[k] = pj;
            } p_result[k] = pj p_result[k] p_result k pj if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            } k == j k j {
              p_result[k] = pi;
            } p_result[k] = pi p_result[k] p_result k pi {
              p_result[k] = p[k];
            } p_result[k] = p[k] p_result[k] p_result k p[k] p k if ( isAscending(p_result) ) {
            return true;
          } isAscending(p_result) isAscending p_result {
            return true;
          } return true; true return false; false int[] p p private static boolean isAscending(int[] p) {
    int n = p.length;
    if ( n < 2 ) {
      return true;
    }
    for(int i = 0; i < n - 1; i++ ) {
      int pi = p[i];
      for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      }
    }
    return true;
  } isAscending {
    int n = p.length;
    if ( n < 2 ) {
      return true;
    }
    for(int i = 0; i < n - 1; i++ ) {
      int pi = p[i];
      for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      }
    }
    return true;
  } int n = p.length; n p.length p p.length if ( n < 2 ) {
      return true;
    } n < 2 n 2 {
      return true;
    } return true; true for(int i = 0; i < n - 1; i++ ) {
      int pi = p[i];
      for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      }
    } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
      int pi = p[i];
      for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      }
    } {
      int pi = p[i];
      for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      }
    } int pi = p[i]; pi p[i] p i for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      } int j = i+1; int j = i+1; j i+1 i 1 j < n j n j++ j++ j {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      } {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      } int pj = p[j]; pj p[j] p j if ( pi > pj ) {
          return false;
        } pi > pj pi pj {
          return false;
        } return false; false return true; true int[] p p public class Main {
  public static void main(String[] args) {
    int N;
    int[] p;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      p = new int[N];
      for(int k = 0; k < N; k++) {
        p[k] = sc.nextInt();
      }
    }
    if ( isOk(p) ) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }
  }
  
  private static boolean isOk(int[] p) {
    int n = p.length;
    if ( isAscending(p) ) {
      return true;
    }
    else {
      for(int i = 0; i < n - 1; i++) {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      }
    }
    return false;
  }
  
  private static boolean isAscending(int[] p) {
    int n = p.length;
    if ( n < 2 ) {
      return true;
    }
    for(int i = 0; i < n - 1; i++ ) {
      int pi = p[i];
      for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      }
    }
    return true;
  }
} public class Main {
  public static void main(String[] args) {
    int N;
    int[] p;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      p = new int[N];
      for(int k = 0; k < N; k++) {
        p[k] = sc.nextInt();
      }
    }
    if ( isOk(p) ) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }
  }
  
  private static boolean isOk(int[] p) {
    int n = p.length;
    if ( isAscending(p) ) {
      return true;
    }
    else {
      for(int i = 0; i < n - 1; i++) {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      }
    }
    return false;
  }
  
  private static boolean isAscending(int[] p) {
    int n = p.length;
    if ( n < 2 ) {
      return true;
    }
    for(int i = 0; i < n - 1; i++ ) {
      int pi = p[i];
      for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      }
    }
    return true;
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int N;
    int[] p;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      p = new int[N];
      for(int k = 0; k < N; k++) {
        p[k] = sc.nextInt();
      }
    }
    if ( isOk(p) ) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }
  }
  
  private static boolean isOk(int[] p) {
    int n = p.length;
    if ( isAscending(p) ) {
      return true;
    }
    else {
      for(int i = 0; i < n - 1; i++) {
        int pi = p[i];
        for (int j = i+1; j < n; j++) {
          int pj = p[j];
          int[] p_result = new int[n];
          for(int k = 0; k < n; k++) {
            if ( k == i ) {
              p_result[k] = pj;
            }
            else if ( k == j ) {
              p_result[k] = pi;
            }
            else {
              p_result[k] = p[k];
            }
          }
          if ( isAscending(p_result) ) {
            return true;
          }
        }
      }
    }
    return false;
  }
  
  private static boolean isAscending(int[] p) {
    int n = p.length;
    if ( n < 2 ) {
      return true;
    }
    for(int i = 0; i < n - 1; i++ ) {
      int pi = p[i];
      for(int j = i+1; j < n; j++ ) {
        int pj = p[j];
        if ( pi > pj ) {
          return false;
        }
      }
    }
    return true;
  }
}