import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int cellNum = scanner.nextInt();
        int cells[] = new int[cellNum];
        boolean reslt = true;

        for (int i = 0; i < cellNum; i++) {
            cells[i] = scanner.nextInt();
        }

        int nextNum = 0;
        for (int i = cellNum; 0 < i; i--) {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        }

        System.out.println(reslt? "Yes": "No");
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int cellNum = scanner.nextInt();
        int cells[] = new int[cellNum];
        boolean reslt = true;

        for (int i = 0; i < cellNum; i++) {
            cells[i] = scanner.nextInt();
        }

        int nextNum = 0;
        for (int i = cellNum; 0 < i; i--) {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        }

        System.out.println(reslt? "Yes": "No");
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int cellNum = scanner.nextInt();
        int cells[] = new int[cellNum];
        boolean reslt = true;

        for (int i = 0; i < cellNum; i++) {
            cells[i] = scanner.nextInt();
        }

        int nextNum = 0;
        for (int i = cellNum; 0 < i; i--) {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        }

        System.out.println(reslt? "Yes": "No");
    } main {
        Scanner scanner = new Scanner(System.in);
        int cellNum = scanner.nextInt();
        int cells[] = new int[cellNum];
        boolean reslt = true;

        for (int i = 0; i < cellNum; i++) {
            cells[i] = scanner.nextInt();
        }

        int nextNum = 0;
        for (int i = cellNum; 0 < i; i--) {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        }

        System.out.println(reslt? "Yes": "No");
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int cellNum = scanner.nextInt(); cellNum scanner.nextInt() scanner.nextInt scanner int cells[] = new int[cellNum]; cells new int[cellNum] cellNum boolean reslt = true; reslt true for (int i = 0; i < cellNum; i++) {
            cells[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < cellNum i cellNum i++ i++ i {
            cells[i] = scanner.nextInt();
        } {
            cells[i] = scanner.nextInt();
        } cells[i] = scanner.nextInt() cells[i] cells i scanner.nextInt() scanner.nextInt scanner int nextNum = 0; nextNum 0 for (int i = cellNum; 0 < i; i--) {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        } int i = cellNum; int i = cellNum; i cellNum 0 < i 0 i i-- i-- i {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        } {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        } if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            } cellNum == i cellNum i {
                nextNum = cells[i - 1];
                continue;
            } nextNum = cells[i - 1] nextNum cells[i - 1] cells i - 1 i 1 continue; int num = cells[i - 1]; num cells[i - 1] cells i - 1 i 1 if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            } num - nextNum > 1 num - nextNum num nextNum 1 {
                reslt = false;
                break;
            } reslt = false reslt false break; if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            } num - nextNum == 1 num - nextNum num nextNum 1 {
                nextNum = num - 1;
            } nextNum = num - 1 nextNum num - 1 num 1 {
                nextNum = num;
            } nextNum = num nextNum num System.out.println(reslt? "Yes": "No") System.out.println System.out System System.out reslt? "Yes": "No" reslt "Yes" "No" String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int cellNum = scanner.nextInt();
        int cells[] = new int[cellNum];
        boolean reslt = true;

        for (int i = 0; i < cellNum; i++) {
            cells[i] = scanner.nextInt();
        }

        int nextNum = 0;
        for (int i = cellNum; 0 < i; i--) {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        }

        System.out.println(reslt? "Yes": "No");
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int cellNum = scanner.nextInt();
        int cells[] = new int[cellNum];
        boolean reslt = true;

        for (int i = 0; i < cellNum; i++) {
            cells[i] = scanner.nextInt();
        }

        int nextNum = 0;
        for (int i = cellNum; 0 < i; i--) {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        }

        System.out.println(reslt? "Yes": "No");
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int cellNum = scanner.nextInt();
        int cells[] = new int[cellNum];
        boolean reslt = true;

        for (int i = 0; i < cellNum; i++) {
            cells[i] = scanner.nextInt();
        }

        int nextNum = 0;
        for (int i = cellNum; 0 < i; i--) {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        }

        System.out.println(reslt? "Yes": "No");
    }
}