import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        List<Integer> list = new ArrayList<Integer>(); 
        for(int i=1; i<=N; i++) {
            list.add(sc.nextInt());
        }
        
        Boolean flag = true;
        Boolean minus = false;
        int onceDesc = -1;
        int left = list.get(0);
        int max = 0;
        for(int i=1; i <N; i++) {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        }
        
        System.out.println(flag? "Yes":"No");
        
    }
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        List<Integer> list = new ArrayList<Integer>(); 
        for(int i=1; i<=N; i++) {
            list.add(sc.nextInt());
        }
        
        Boolean flag = true;
        Boolean minus = false;
        int onceDesc = -1;
        int left = list.get(0);
        int max = 0;
        for(int i=1; i <N; i++) {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        }
        
        System.out.println(flag? "Yes":"No");
        
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        List<Integer> list = new ArrayList<Integer>(); 
        for(int i=1; i<=N; i++) {
            list.add(sc.nextInt());
        }
        
        Boolean flag = true;
        Boolean minus = false;
        int onceDesc = -1;
        int left = list.get(0);
        int max = 0;
        for(int i=1; i <N; i++) {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        }
        
        System.out.println(flag? "Yes":"No");
        
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        List<Integer> list = new ArrayList<Integer>(); 
        for(int i=1; i<=N; i++) {
            list.add(sc.nextInt());
        }
        
        Boolean flag = true;
        Boolean minus = false;
        int onceDesc = -1;
        int left = list.get(0);
        int max = 0;
        for(int i=1; i <N; i++) {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        }
        
        System.out.println(flag? "Yes":"No");
        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for(int i=1; i<=N; i++) {
            list.add(sc.nextInt());
        } int i=1; int i=1; i 1 i<=N i N i++ i++ i {
            list.add(sc.nextInt());
        } {
            list.add(sc.nextInt());
        } list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc Boolean flag = true; flag true Boolean minus = false; minus false int onceDesc = -1; onceDesc -1 1 int left = list.get(0); left list.get(0) list.get list 0 int max = 0; max 0 for(int i=1; i <N; i++) {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        } int i=1; int i=1; i 1 i <N i N i++ i++ i {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        } {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        } if(list.get(i) > max) {
                max = list.get(i); 
            } list.get(i) > max list.get(i) list.get list i max {
                max = list.get(i); 
            } max = list.get(i) max list.get(i) list.get list i if(max - list.get(i) > 1) {
                flag = false;
                break;
            } max - list.get(i) > 1 max - list.get(i) max list.get(i) list.get list i 1 {
                flag = false;
                break;
            } flag = false flag false break; if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            } list.get(i) >= left list.get(i) list.get list i left {
//                System.out.println(list.get(i));
                left = list.get(i);
            } left = list.get(i) left list.get(i) list.get list i if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            } list.get(i) < left list.get(i) list.get list i left {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            } if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                } left - list.get(i) > 1 left - list.get(i) left list.get(i) list.get list i 1 {
                    flag = false;
                    break;
                } flag = false flag false break; if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                } left - list.get(i) ==1 left - list.get(i) left list.get(i) list.get list i 1 {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                } left -= 1 left 1 System.out.println(flag? "Yes":"No") System.out.println System.out System System.out flag? "Yes":"No" flag "Yes" "No" String[] args args public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        List<Integer> list = new ArrayList<Integer>(); 
        for(int i=1; i<=N; i++) {
            list.add(sc.nextInt());
        }
        
        Boolean flag = true;
        Boolean minus = false;
        int onceDesc = -1;
        int left = list.get(0);
        int max = 0;
        for(int i=1; i <N; i++) {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        }
        
        System.out.println(flag? "Yes":"No");
        
    }
} public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        List<Integer> list = new ArrayList<Integer>(); 
        for(int i=1; i<=N; i++) {
            list.add(sc.nextInt());
        }
        
        Boolean flag = true;
        Boolean minus = false;
        int onceDesc = -1;
        int left = list.get(0);
        int max = 0;
        for(int i=1; i <N; i++) {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        }
        
        System.out.println(flag? "Yes":"No");
        
    }
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        List<Integer> list = new ArrayList<Integer>(); 
        for(int i=1; i<=N; i++) {
            list.add(sc.nextInt());
        }
        
        Boolean flag = true;
        Boolean minus = false;
        int onceDesc = -1;
        int left = list.get(0);
        int max = 0;
        for(int i=1; i <N; i++) {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        }
        
        System.out.println(flag? "Yes":"No");
        
    }
}