import java.util.*;

public class Main {
  public static void main(String[] args) {
    int N;
    int[] H;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      H = new int[N];
      for(int i = 0; i < N; i++) {
        H[i] = sc.nextInt();
      }
    }
    DataSet indata = new DataSet(N, H);
    Result answer = canBuildStair(indata, Integer.MAX_VALUE);
    System.out.println(answer.isSuccess() ? "Yes": "No");
  }
  
  private static Result canBuildStair(DataSet dataSet, int max) {
    int n = dataSet.size();
    if ( n == 0 ) {
      return new Result(dataSet, true);
    }
    int lastValue = dataSet.lastValue();
    int shift = 0;
    if ( lastValue > max ) {
      shift = -1;
    }
    if ( shift < 0 && lastValue - 1 > max ) {
      return new Result(dataSet, false);
    }
    DataSet[] children = dataSet.children();
    DataSet left = children[0];
    DataSet right = children[1];
    
    Result leftResult = null;
    Result rightResult = null;
    if ( right.isEmpty() ) {
      rightResult = new Result(right, true);
      leftResult = canBuildStair(left, lastValue + shift);
    }
    else {
      rightResult = canBuildStair(right, lastValue + shift);
      if ( rightResult.isSuccess() == false ) {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      }
      leftResult = canBuildStair(left, rightResult.firstValue());
    }
    
    DataSet resultData = DataSet.concat(leftResult.dataSet(), rightResult.dataSet(), lastValue + shift);
    return new Result(resultData, leftResult.isSuccess());
  }
  
  private static class Result {
    private final DataSet dataSet;
    private final boolean bResult;

    public Result(DataSet dataSet, boolean bResult) {
      this.dataSet = dataSet;
      this.bResult = bResult;
    }

    public boolean isSuccess() {
      return bResult;
    }

    public DataSet dataSet() {
      return dataSet.clone();
    }

    public int firstValue() {
      return dataSet.firstValue();
    }
  }

  private static class DataSet {
    private final int n;
    private final int[] h;

    public DataSet(int n, int[] h) {
      this.n = n;
      this.h = h;
    }

    public int size() {
      return n;
    }
    
    public boolean isEmpty() {
      return n < 1;
    }

    public int firstValue() {
      return h[0];
    }

    public int lastValue() {
      return h[n-1];
    }

    public DataSet clone() {
      return new DataSet(n, h());
    }

    private int[] h() {
      int[] hCopied = new int[n];
      for(int i = 0; i < n; i++) {
        hCopied[i] = h[i];
      }
      return hCopied;
    }

    public static DataSet concat(DataSet d1, DataSet d2, int lastValue) {
      int n1 = d1.size();
      int n2 = d2.size();
      int nn = n1 + n2 + 1;
      int[] hh = new int[nn];
      int[] h1 = d1.h();
      for ( int i = 0; i < n1; i++ ) {
        hh[i] = h1[i];
      }
      int[] h2 = d2.h();
      for ( int i = 0; i < n2; i++ ) {
        hh[n1+i] = h2[i];
      }
      hh[nn-1] = lastValue;
      return new DataSet(nn, hh);
    }

    public DataSet[] children() {
      int n0 = (int)(Math.floor((n-1)/2));
      int n1 = (n-1) - n0;
      int[] h0 = new int[n0];
      for(int i = 0; i < n0; i++) {
        h0[i] = h[i];
      }
      int[] h1 = new int[n1];
      for(int i = 0; i < n1; i++) {
        h1[i] = h[n0 + i];
      }
      DataSet[] children = new DataSet[2];
      children[0] = new DataSet(n0, h0);
      children[1] = new DataSet(n1, h1);
      return children;
    }
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    int N;
    int[] H;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      H = new int[N];
      for(int i = 0; i < N; i++) {
        H[i] = sc.nextInt();
      }
    }
    DataSet indata = new DataSet(N, H);
    Result answer = canBuildStair(indata, Integer.MAX_VALUE);
    System.out.println(answer.isSuccess() ? "Yes": "No");
  }
  
  private static Result canBuildStair(DataSet dataSet, int max) {
    int n = dataSet.size();
    if ( n == 0 ) {
      return new Result(dataSet, true);
    }
    int lastValue = dataSet.lastValue();
    int shift = 0;
    if ( lastValue > max ) {
      shift = -1;
    }
    if ( shift < 0 && lastValue - 1 > max ) {
      return new Result(dataSet, false);
    }
    DataSet[] children = dataSet.children();
    DataSet left = children[0];
    DataSet right = children[1];
    
    Result leftResult = null;
    Result rightResult = null;
    if ( right.isEmpty() ) {
      rightResult = new Result(right, true);
      leftResult = canBuildStair(left, lastValue + shift);
    }
    else {
      rightResult = canBuildStair(right, lastValue + shift);
      if ( rightResult.isSuccess() == false ) {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      }
      leftResult = canBuildStair(left, rightResult.firstValue());
    }
    
    DataSet resultData = DataSet.concat(leftResult.dataSet(), rightResult.dataSet(), lastValue + shift);
    return new Result(resultData, leftResult.isSuccess());
  }
  
  private static class Result {
    private final DataSet dataSet;
    private final boolean bResult;

    public Result(DataSet dataSet, boolean bResult) {
      this.dataSet = dataSet;
      this.bResult = bResult;
    }

    public boolean isSuccess() {
      return bResult;
    }

    public DataSet dataSet() {
      return dataSet.clone();
    }

    public int firstValue() {
      return dataSet.firstValue();
    }
  }

  private static class DataSet {
    private final int n;
    private final int[] h;

    public DataSet(int n, int[] h) {
      this.n = n;
      this.h = h;
    }

    public int size() {
      return n;
    }
    
    public boolean isEmpty() {
      return n < 1;
    }

    public int firstValue() {
      return h[0];
    }

    public int lastValue() {
      return h[n-1];
    }

    public DataSet clone() {
      return new DataSet(n, h());
    }

    private int[] h() {
      int[] hCopied = new int[n];
      for(int i = 0; i < n; i++) {
        hCopied[i] = h[i];
      }
      return hCopied;
    }

    public static DataSet concat(DataSet d1, DataSet d2, int lastValue) {
      int n1 = d1.size();
      int n2 = d2.size();
      int nn = n1 + n2 + 1;
      int[] hh = new int[nn];
      int[] h1 = d1.h();
      for ( int i = 0; i < n1; i++ ) {
        hh[i] = h1[i];
      }
      int[] h2 = d2.h();
      for ( int i = 0; i < n2; i++ ) {
        hh[n1+i] = h2[i];
      }
      hh[nn-1] = lastValue;
      return new DataSet(nn, hh);
    }

    public DataSet[] children() {
      int n0 = (int)(Math.floor((n-1)/2));
      int n1 = (n-1) - n0;
      int[] h0 = new int[n0];
      for(int i = 0; i < n0; i++) {
        h0[i] = h[i];
      }
      int[] h1 = new int[n1];
      for(int i = 0; i < n1; i++) {
        h1[i] = h[n0 + i];
      }
      DataSet[] children = new DataSet[2];
      children[0] = new DataSet(n0, h0);
      children[1] = new DataSet(n1, h1);
      return children;
    }
  }
} Main public static void main(String[] args) {
    int N;
    int[] H;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      H = new int[N];
      for(int i = 0; i < N; i++) {
        H[i] = sc.nextInt();
      }
    }
    DataSet indata = new DataSet(N, H);
    Result answer = canBuildStair(indata, Integer.MAX_VALUE);
    System.out.println(answer.isSuccess() ? "Yes": "No");
  } main {
    int N;
    int[] H;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      H = new int[N];
      for(int i = 0; i < N; i++) {
        H[i] = sc.nextInt();
      }
    }
    DataSet indata = new DataSet(N, H);
    Result answer = canBuildStair(indata, Integer.MAX_VALUE);
    System.out.println(answer.isSuccess() ? "Yes": "No");
  } int N; N int[] H; H try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      H = new int[N];
      for(int i = 0; i < N; i++) {
        H[i] = sc.nextInt();
      }
    } {
      N = sc.nextInt();
      H = new int[N];
      for(int i = 0; i < N; i++) {
        H[i] = 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 H = new int[N] H new int[N] N for(int i = 0; i < N; i++) {
        H[i] = sc.nextInt();
      } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
        H[i] = sc.nextInt();
      } {
        H[i] = sc.nextInt();
      } H[i] = sc.nextInt() H[i] H i sc.nextInt() sc.nextInt sc DataSet indata = new DataSet(N, H); indata new DataSet(N, H) Result answer = canBuildStair(indata, Integer.MAX_VALUE); answer canBuildStair(indata, Integer.MAX_VALUE) canBuildStair indata Integer.MAX_VALUE Integer Integer.MAX_VALUE System.out.println(answer.isSuccess() ? "Yes": "No") System.out.println System.out System System.out answer.isSuccess() ? "Yes": "No" answer.isSuccess() answer.isSuccess answer "Yes" "No" String[] args args private static Result canBuildStair(DataSet dataSet, int max) {
    int n = dataSet.size();
    if ( n == 0 ) {
      return new Result(dataSet, true);
    }
    int lastValue = dataSet.lastValue();
    int shift = 0;
    if ( lastValue > max ) {
      shift = -1;
    }
    if ( shift < 0 && lastValue - 1 > max ) {
      return new Result(dataSet, false);
    }
    DataSet[] children = dataSet.children();
    DataSet left = children[0];
    DataSet right = children[1];
    
    Result leftResult = null;
    Result rightResult = null;
    if ( right.isEmpty() ) {
      rightResult = new Result(right, true);
      leftResult = canBuildStair(left, lastValue + shift);
    }
    else {
      rightResult = canBuildStair(right, lastValue + shift);
      if ( rightResult.isSuccess() == false ) {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      }
      leftResult = canBuildStair(left, rightResult.firstValue());
    }
    
    DataSet resultData = DataSet.concat(leftResult.dataSet(), rightResult.dataSet(), lastValue + shift);
    return new Result(resultData, leftResult.isSuccess());
  } canBuildStair {
    int n = dataSet.size();
    if ( n == 0 ) {
      return new Result(dataSet, true);
    }
    int lastValue = dataSet.lastValue();
    int shift = 0;
    if ( lastValue > max ) {
      shift = -1;
    }
    if ( shift < 0 && lastValue - 1 > max ) {
      return new Result(dataSet, false);
    }
    DataSet[] children = dataSet.children();
    DataSet left = children[0];
    DataSet right = children[1];
    
    Result leftResult = null;
    Result rightResult = null;
    if ( right.isEmpty() ) {
      rightResult = new Result(right, true);
      leftResult = canBuildStair(left, lastValue + shift);
    }
    else {
      rightResult = canBuildStair(right, lastValue + shift);
      if ( rightResult.isSuccess() == false ) {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      }
      leftResult = canBuildStair(left, rightResult.firstValue());
    }
    
    DataSet resultData = DataSet.concat(leftResult.dataSet(), rightResult.dataSet(), lastValue + shift);
    return new Result(resultData, leftResult.isSuccess());
  } int n = dataSet.size(); n dataSet.size() dataSet.size dataSet if ( n == 0 ) {
      return new Result(dataSet, true);
    } n == 0 n 0 {
      return new Result(dataSet, true);
    } return new Result(dataSet, true); new Result(dataSet, true) int lastValue = dataSet.lastValue(); lastValue dataSet.lastValue() dataSet.lastValue dataSet int shift = 0; shift 0 if ( lastValue > max ) {
      shift = -1;
    } lastValue > max lastValue max {
      shift = -1;
    } shift = -1 shift -1 1 if ( shift < 0 && lastValue - 1 > max ) {
      return new Result(dataSet, false);
    } shift < 0 && lastValue - 1 > max shift < 0 shift 0 lastValue - 1 > max lastValue - 1 lastValue 1 max {
      return new Result(dataSet, false);
    } return new Result(dataSet, false); new Result(dataSet, false) DataSet[] children = dataSet.children(); children dataSet.children() dataSet.children dataSet DataSet left = children[0]; left children[0] children 0 DataSet right = children[1]; right children[1] children 1 Result leftResult = null; leftResult null Result rightResult = null; rightResult null if ( right.isEmpty() ) {
      rightResult = new Result(right, true);
      leftResult = canBuildStair(left, lastValue + shift);
    }
    else {
      rightResult = canBuildStair(right, lastValue + shift);
      if ( rightResult.isSuccess() == false ) {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      }
      leftResult = canBuildStair(left, rightResult.firstValue());
    } right.isEmpty() right.isEmpty right {
      rightResult = new Result(right, true);
      leftResult = canBuildStair(left, lastValue + shift);
    } rightResult = new Result(right, true) rightResult new Result(right, true) leftResult = canBuildStair(left, lastValue + shift) leftResult canBuildStair(left, lastValue + shift) canBuildStair left lastValue + shift lastValue shift {
      rightResult = canBuildStair(right, lastValue + shift);
      if ( rightResult.isSuccess() == false ) {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      }
      leftResult = canBuildStair(left, rightResult.firstValue());
    } rightResult = canBuildStair(right, lastValue + shift) rightResult canBuildStair(right, lastValue + shift) canBuildStair right lastValue + shift lastValue shift if ( rightResult.isSuccess() == false ) {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      } rightResult.isSuccess() == false rightResult.isSuccess() rightResult.isSuccess rightResult false {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      } DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift); resultData DataSet.concat(left, rightResult.dataSet(), lastValue + shift) DataSet.concat DataSet left rightResult.dataSet() rightResult.dataSet rightResult lastValue + shift lastValue shift return new Result(resultData, false); new Result(resultData, false) leftResult = canBuildStair(left, rightResult.firstValue()) leftResult canBuildStair(left, rightResult.firstValue()) canBuildStair left rightResult.firstValue() rightResult.firstValue rightResult DataSet resultData = DataSet.concat(leftResult.dataSet(), rightResult.dataSet(), lastValue + shift); resultData DataSet.concat(leftResult.dataSet(), rightResult.dataSet(), lastValue + shift) DataSet.concat DataSet leftResult.dataSet() leftResult.dataSet leftResult rightResult.dataSet() rightResult.dataSet rightResult lastValue + shift lastValue shift return new Result(resultData, leftResult.isSuccess()); new Result(resultData, leftResult.isSuccess()) DataSet dataSet dataSet int max max private static class Result {
    private final DataSet dataSet;
    private final boolean bResult;

    public Result(DataSet dataSet, boolean bResult) {
      this.dataSet = dataSet;
      this.bResult = bResult;
    }

    public boolean isSuccess() {
      return bResult;
    }

    public DataSet dataSet() {
      return dataSet.clone();
    }

    public int firstValue() {
      return dataSet.firstValue();
    }
  } Result private final DataSet dataSet; dataSet private final boolean bResult; bResult public Result(DataSet dataSet, boolean bResult) {
      this.dataSet = dataSet;
      this.bResult = bResult;
    } Result {
      this.dataSet = dataSet;
      this.bResult = bResult;
    } this.dataSet = dataSet this.dataSet this this.dataSet dataSet this.bResult = bResult this.bResult this this.bResult bResult DataSet dataSet dataSet boolean bResult bResult public boolean isSuccess() {
      return bResult;
    } isSuccess {
      return bResult;
    } return bResult; bResult public DataSet dataSet() {
      return dataSet.clone();
    } dataSet {
      return dataSet.clone();
    } return dataSet.clone(); dataSet.clone() dataSet.clone dataSet public int firstValue() {
      return dataSet.firstValue();
    } firstValue {
      return dataSet.firstValue();
    } return dataSet.firstValue(); dataSet.firstValue() dataSet.firstValue dataSet private static class DataSet {
    private final int n;
    private final int[] h;

    public DataSet(int n, int[] h) {
      this.n = n;
      this.h = h;
    }

    public int size() {
      return n;
    }
    
    public boolean isEmpty() {
      return n < 1;
    }

    public int firstValue() {
      return h[0];
    }

    public int lastValue() {
      return h[n-1];
    }

    public DataSet clone() {
      return new DataSet(n, h());
    }

    private int[] h() {
      int[] hCopied = new int[n];
      for(int i = 0; i < n; i++) {
        hCopied[i] = h[i];
      }
      return hCopied;
    }

    public static DataSet concat(DataSet d1, DataSet d2, int lastValue) {
      int n1 = d1.size();
      int n2 = d2.size();
      int nn = n1 + n2 + 1;
      int[] hh = new int[nn];
      int[] h1 = d1.h();
      for ( int i = 0; i < n1; i++ ) {
        hh[i] = h1[i];
      }
      int[] h2 = d2.h();
      for ( int i = 0; i < n2; i++ ) {
        hh[n1+i] = h2[i];
      }
      hh[nn-1] = lastValue;
      return new DataSet(nn, hh);
    }

    public DataSet[] children() {
      int n0 = (int)(Math.floor((n-1)/2));
      int n1 = (n-1) - n0;
      int[] h0 = new int[n0];
      for(int i = 0; i < n0; i++) {
        h0[i] = h[i];
      }
      int[] h1 = new int[n1];
      for(int i = 0; i < n1; i++) {
        h1[i] = h[n0 + i];
      }
      DataSet[] children = new DataSet[2];
      children[0] = new DataSet(n0, h0);
      children[1] = new DataSet(n1, h1);
      return children;
    }
  } DataSet private final int n; n private final int[] h; h public DataSet(int n, int[] h) {
      this.n = n;
      this.h = h;
    } DataSet {
      this.n = n;
      this.h = h;
    } this.n = n this.n this this.n n this.h = h this.h this this.h h int n n int[] h h public int size() {
      return n;
    } size {
      return n;
    } return n; n public boolean isEmpty() {
      return n < 1;
    } isEmpty {
      return n < 1;
    } return n < 1; n < 1 n 1 public int firstValue() {
      return h[0];
    } firstValue {
      return h[0];
    } return h[0]; h[0] h 0 public int lastValue() {
      return h[n-1];
    } lastValue {
      return h[n-1];
    } return h[n-1]; h[n-1] h n-1 n 1 public DataSet clone() {
      return new DataSet(n, h());
    } clone {
      return new DataSet(n, h());
    } return new DataSet(n, h()); new DataSet(n, h()) private int[] h() {
      int[] hCopied = new int[n];
      for(int i = 0; i < n; i++) {
        hCopied[i] = h[i];
      }
      return hCopied;
    } h {
      int[] hCopied = new int[n];
      for(int i = 0; i < n; i++) {
        hCopied[i] = h[i];
      }
      return hCopied;
    } int[] hCopied = new int[n]; hCopied new int[n] n for(int i = 0; i < n; i++) {
        hCopied[i] = h[i];
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        hCopied[i] = h[i];
      } {
        hCopied[i] = h[i];
      } hCopied[i] = h[i] hCopied[i] hCopied i h[i] h i return hCopied; hCopied public static DataSet concat(DataSet d1, DataSet d2, int lastValue) {
      int n1 = d1.size();
      int n2 = d2.size();
      int nn = n1 + n2 + 1;
      int[] hh = new int[nn];
      int[] h1 = d1.h();
      for ( int i = 0; i < n1; i++ ) {
        hh[i] = h1[i];
      }
      int[] h2 = d2.h();
      for ( int i = 0; i < n2; i++ ) {
        hh[n1+i] = h2[i];
      }
      hh[nn-1] = lastValue;
      return new DataSet(nn, hh);
    } concat {
      int n1 = d1.size();
      int n2 = d2.size();
      int nn = n1 + n2 + 1;
      int[] hh = new int[nn];
      int[] h1 = d1.h();
      for ( int i = 0; i < n1; i++ ) {
        hh[i] = h1[i];
      }
      int[] h2 = d2.h();
      for ( int i = 0; i < n2; i++ ) {
        hh[n1+i] = h2[i];
      }
      hh[nn-1] = lastValue;
      return new DataSet(nn, hh);
    } int n1 = d1.size(); n1 d1.size() d1.size d1 int n2 = d2.size(); n2 d2.size() d2.size d2 int nn = n1 + n2 + 1; nn n1 + n2 + 1 n1 + n2 + 1 n1 n2 1 int[] hh = new int[nn]; hh new int[nn] nn int[] h1 = d1.h(); h1 d1.h() d1.h d1 for ( int i = 0; i < n1; i++ ) {
        hh[i] = h1[i];
      } int i = 0; int i = 0; i 0 i < n1 i n1 i++ i++ i {
        hh[i] = h1[i];
      } {
        hh[i] = h1[i];
      } hh[i] = h1[i] hh[i] hh i h1[i] h1 i int[] h2 = d2.h(); h2 d2.h() d2.h d2 for ( int i = 0; i < n2; i++ ) {
        hh[n1+i] = h2[i];
      } int i = 0; int i = 0; i 0 i < n2 i n2 i++ i++ i {
        hh[n1+i] = h2[i];
      } {
        hh[n1+i] = h2[i];
      } hh[n1+i] = h2[i] hh[n1+i] hh n1+i n1 i h2[i] h2 i hh[nn-1] = lastValue hh[nn-1] hh nn-1 nn 1 lastValue return new DataSet(nn, hh); new DataSet(nn, hh) DataSet d1 d1 DataSet d2 d2 int lastValue lastValue public DataSet[] children() {
      int n0 = (int)(Math.floor((n-1)/2));
      int n1 = (n-1) - n0;
      int[] h0 = new int[n0];
      for(int i = 0; i < n0; i++) {
        h0[i] = h[i];
      }
      int[] h1 = new int[n1];
      for(int i = 0; i < n1; i++) {
        h1[i] = h[n0 + i];
      }
      DataSet[] children = new DataSet[2];
      children[0] = new DataSet(n0, h0);
      children[1] = new DataSet(n1, h1);
      return children;
    } children {
      int n0 = (int)(Math.floor((n-1)/2));
      int n1 = (n-1) - n0;
      int[] h0 = new int[n0];
      for(int i = 0; i < n0; i++) {
        h0[i] = h[i];
      }
      int[] h1 = new int[n1];
      for(int i = 0; i < n1; i++) {
        h1[i] = h[n0 + i];
      }
      DataSet[] children = new DataSet[2];
      children[0] = new DataSet(n0, h0);
      children[1] = new DataSet(n1, h1);
      return children;
    } int n0 = (int)(Math.floor((n-1)/2)); n0 (int)(Math.floor((n-1)/2)) Math.floor Math (n-1)/2 (n-1) n 1 2 int n1 = (n-1) - n0; n1 (n-1) - n0 (n-1) n 1 n0 int[] h0 = new int[n0]; h0 new int[n0] n0 for(int i = 0; i < n0; i++) {
        h0[i] = h[i];
      } int i = 0; int i = 0; i 0 i < n0 i n0 i++ i++ i {
        h0[i] = h[i];
      } {
        h0[i] = h[i];
      } h0[i] = h[i] h0[i] h0 i h[i] h i int[] h1 = new int[n1]; h1 new int[n1] n1 for(int i = 0; i < n1; i++) {
        h1[i] = h[n0 + i];
      } int i = 0; int i = 0; i 0 i < n1 i n1 i++ i++ i {
        h1[i] = h[n0 + i];
      } {
        h1[i] = h[n0 + i];
      } h1[i] = h[n0 + i] h1[i] h1 i h[n0 + i] h n0 + i n0 i DataSet[] children = new DataSet[2]; children new DataSet[2] 2 children[0] = new DataSet(n0, h0) children[0] children 0 new DataSet(n0, h0) children[1] = new DataSet(n1, h1) children[1] children 1 new DataSet(n1, h1) return children; children public class Main {
  public static void main(String[] args) {
    int N;
    int[] H;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      H = new int[N];
      for(int i = 0; i < N; i++) {
        H[i] = sc.nextInt();
      }
    }
    DataSet indata = new DataSet(N, H);
    Result answer = canBuildStair(indata, Integer.MAX_VALUE);
    System.out.println(answer.isSuccess() ? "Yes": "No");
  }
  
  private static Result canBuildStair(DataSet dataSet, int max) {
    int n = dataSet.size();
    if ( n == 0 ) {
      return new Result(dataSet, true);
    }
    int lastValue = dataSet.lastValue();
    int shift = 0;
    if ( lastValue > max ) {
      shift = -1;
    }
    if ( shift < 0 && lastValue - 1 > max ) {
      return new Result(dataSet, false);
    }
    DataSet[] children = dataSet.children();
    DataSet left = children[0];
    DataSet right = children[1];
    
    Result leftResult = null;
    Result rightResult = null;
    if ( right.isEmpty() ) {
      rightResult = new Result(right, true);
      leftResult = canBuildStair(left, lastValue + shift);
    }
    else {
      rightResult = canBuildStair(right, lastValue + shift);
      if ( rightResult.isSuccess() == false ) {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      }
      leftResult = canBuildStair(left, rightResult.firstValue());
    }
    
    DataSet resultData = DataSet.concat(leftResult.dataSet(), rightResult.dataSet(), lastValue + shift);
    return new Result(resultData, leftResult.isSuccess());
  }
  
  private static class Result {
    private final DataSet dataSet;
    private final boolean bResult;

    public Result(DataSet dataSet, boolean bResult) {
      this.dataSet = dataSet;
      this.bResult = bResult;
    }

    public boolean isSuccess() {
      return bResult;
    }

    public DataSet dataSet() {
      return dataSet.clone();
    }

    public int firstValue() {
      return dataSet.firstValue();
    }
  }

  private static class DataSet {
    private final int n;
    private final int[] h;

    public DataSet(int n, int[] h) {
      this.n = n;
      this.h = h;
    }

    public int size() {
      return n;
    }
    
    public boolean isEmpty() {
      return n < 1;
    }

    public int firstValue() {
      return h[0];
    }

    public int lastValue() {
      return h[n-1];
    }

    public DataSet clone() {
      return new DataSet(n, h());
    }

    private int[] h() {
      int[] hCopied = new int[n];
      for(int i = 0; i < n; i++) {
        hCopied[i] = h[i];
      }
      return hCopied;
    }

    public static DataSet concat(DataSet d1, DataSet d2, int lastValue) {
      int n1 = d1.size();
      int n2 = d2.size();
      int nn = n1 + n2 + 1;
      int[] hh = new int[nn];
      int[] h1 = d1.h();
      for ( int i = 0; i < n1; i++ ) {
        hh[i] = h1[i];
      }
      int[] h2 = d2.h();
      for ( int i = 0; i < n2; i++ ) {
        hh[n1+i] = h2[i];
      }
      hh[nn-1] = lastValue;
      return new DataSet(nn, hh);
    }

    public DataSet[] children() {
      int n0 = (int)(Math.floor((n-1)/2));
      int n1 = (n-1) - n0;
      int[] h0 = new int[n0];
      for(int i = 0; i < n0; i++) {
        h0[i] = h[i];
      }
      int[] h1 = new int[n1];
      for(int i = 0; i < n1; i++) {
        h1[i] = h[n0 + i];
      }
      DataSet[] children = new DataSet[2];
      children[0] = new DataSet(n0, h0);
      children[1] = new DataSet(n1, h1);
      return children;
    }
  }
} public class Main {
  public static void main(String[] args) {
    int N;
    int[] H;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      H = new int[N];
      for(int i = 0; i < N; i++) {
        H[i] = sc.nextInt();
      }
    }
    DataSet indata = new DataSet(N, H);
    Result answer = canBuildStair(indata, Integer.MAX_VALUE);
    System.out.println(answer.isSuccess() ? "Yes": "No");
  }
  
  private static Result canBuildStair(DataSet dataSet, int max) {
    int n = dataSet.size();
    if ( n == 0 ) {
      return new Result(dataSet, true);
    }
    int lastValue = dataSet.lastValue();
    int shift = 0;
    if ( lastValue > max ) {
      shift = -1;
    }
    if ( shift < 0 && lastValue - 1 > max ) {
      return new Result(dataSet, false);
    }
    DataSet[] children = dataSet.children();
    DataSet left = children[0];
    DataSet right = children[1];
    
    Result leftResult = null;
    Result rightResult = null;
    if ( right.isEmpty() ) {
      rightResult = new Result(right, true);
      leftResult = canBuildStair(left, lastValue + shift);
    }
    else {
      rightResult = canBuildStair(right, lastValue + shift);
      if ( rightResult.isSuccess() == false ) {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      }
      leftResult = canBuildStair(left, rightResult.firstValue());
    }
    
    DataSet resultData = DataSet.concat(leftResult.dataSet(), rightResult.dataSet(), lastValue + shift);
    return new Result(resultData, leftResult.isSuccess());
  }
  
  private static class Result {
    private final DataSet dataSet;
    private final boolean bResult;

    public Result(DataSet dataSet, boolean bResult) {
      this.dataSet = dataSet;
      this.bResult = bResult;
    }

    public boolean isSuccess() {
      return bResult;
    }

    public DataSet dataSet() {
      return dataSet.clone();
    }

    public int firstValue() {
      return dataSet.firstValue();
    }
  }

  private static class DataSet {
    private final int n;
    private final int[] h;

    public DataSet(int n, int[] h) {
      this.n = n;
      this.h = h;
    }

    public int size() {
      return n;
    }
    
    public boolean isEmpty() {
      return n < 1;
    }

    public int firstValue() {
      return h[0];
    }

    public int lastValue() {
      return h[n-1];
    }

    public DataSet clone() {
      return new DataSet(n, h());
    }

    private int[] h() {
      int[] hCopied = new int[n];
      for(int i = 0; i < n; i++) {
        hCopied[i] = h[i];
      }
      return hCopied;
    }

    public static DataSet concat(DataSet d1, DataSet d2, int lastValue) {
      int n1 = d1.size();
      int n2 = d2.size();
      int nn = n1 + n2 + 1;
      int[] hh = new int[nn];
      int[] h1 = d1.h();
      for ( int i = 0; i < n1; i++ ) {
        hh[i] = h1[i];
      }
      int[] h2 = d2.h();
      for ( int i = 0; i < n2; i++ ) {
        hh[n1+i] = h2[i];
      }
      hh[nn-1] = lastValue;
      return new DataSet(nn, hh);
    }

    public DataSet[] children() {
      int n0 = (int)(Math.floor((n-1)/2));
      int n1 = (n-1) - n0;
      int[] h0 = new int[n0];
      for(int i = 0; i < n0; i++) {
        h0[i] = h[i];
      }
      int[] h1 = new int[n1];
      for(int i = 0; i < n1; i++) {
        h1[i] = h[n0 + i];
      }
      DataSet[] children = new DataSet[2];
      children[0] = new DataSet(n0, h0);
      children[1] = new DataSet(n1, h1);
      return children;
    }
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int N;
    int[] H;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      H = new int[N];
      for(int i = 0; i < N; i++) {
        H[i] = sc.nextInt();
      }
    }
    DataSet indata = new DataSet(N, H);
    Result answer = canBuildStair(indata, Integer.MAX_VALUE);
    System.out.println(answer.isSuccess() ? "Yes": "No");
  }
  
  private static Result canBuildStair(DataSet dataSet, int max) {
    int n = dataSet.size();
    if ( n == 0 ) {
      return new Result(dataSet, true);
    }
    int lastValue = dataSet.lastValue();
    int shift = 0;
    if ( lastValue > max ) {
      shift = -1;
    }
    if ( shift < 0 && lastValue - 1 > max ) {
      return new Result(dataSet, false);
    }
    DataSet[] children = dataSet.children();
    DataSet left = children[0];
    DataSet right = children[1];
    
    Result leftResult = null;
    Result rightResult = null;
    if ( right.isEmpty() ) {
      rightResult = new Result(right, true);
      leftResult = canBuildStair(left, lastValue + shift);
    }
    else {
      rightResult = canBuildStair(right, lastValue + shift);
      if ( rightResult.isSuccess() == false ) {
        DataSet resultData = DataSet.concat(left, rightResult.dataSet(), lastValue + shift);
        return new Result(resultData, false);
      }
      leftResult = canBuildStair(left, rightResult.firstValue());
    }
    
    DataSet resultData = DataSet.concat(leftResult.dataSet(), rightResult.dataSet(), lastValue + shift);
    return new Result(resultData, leftResult.isSuccess());
  }
  
  private static class Result {
    private final DataSet dataSet;
    private final boolean bResult;

    public Result(DataSet dataSet, boolean bResult) {
      this.dataSet = dataSet;
      this.bResult = bResult;
    }

    public boolean isSuccess() {
      return bResult;
    }

    public DataSet dataSet() {
      return dataSet.clone();
    }

    public int firstValue() {
      return dataSet.firstValue();
    }
  }

  private static class DataSet {
    private final int n;
    private final int[] h;

    public DataSet(int n, int[] h) {
      this.n = n;
      this.h = h;
    }

    public int size() {
      return n;
    }
    
    public boolean isEmpty() {
      return n < 1;
    }

    public int firstValue() {
      return h[0];
    }

    public int lastValue() {
      return h[n-1];
    }

    public DataSet clone() {
      return new DataSet(n, h());
    }

    private int[] h() {
      int[] hCopied = new int[n];
      for(int i = 0; i < n; i++) {
        hCopied[i] = h[i];
      }
      return hCopied;
    }

    public static DataSet concat(DataSet d1, DataSet d2, int lastValue) {
      int n1 = d1.size();
      int n2 = d2.size();
      int nn = n1 + n2 + 1;
      int[] hh = new int[nn];
      int[] h1 = d1.h();
      for ( int i = 0; i < n1; i++ ) {
        hh[i] = h1[i];
      }
      int[] h2 = d2.h();
      for ( int i = 0; i < n2; i++ ) {
        hh[n1+i] = h2[i];
      }
      hh[nn-1] = lastValue;
      return new DataSet(nn, hh);
    }

    public DataSet[] children() {
      int n0 = (int)(Math.floor((n-1)/2));
      int n1 = (n-1) - n0;
      int[] h0 = new int[n0];
      for(int i = 0; i < n0; i++) {
        h0[i] = h[i];
      }
      int[] h1 = new int[n1];
      for(int i = 0; i < n1; i++) {
        h1[i] = h[n0 + i];
      }
      DataSet[] children = new DataSet[2];
      children[0] = new DataSet(n0, h0);
      children[1] = new DataSet(n1, h1);
      return children;
    }
  }
}