import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
	
		try {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

			int n = Integer.parseInt(bf.readLine().trim());

			int p[] = new int[n+1];
			int i=1;
			
		    StringTokenizer st = new StringTokenizer(bf.readLine().trim());
		    while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    }
		    
		    boolean ret = true;
		    for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    }
		    
		    if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    }
		}catch(Exception e){
			e.printStackTrace();
		}
	
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	public static void main(String[] args) {
	
		try {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

			int n = Integer.parseInt(bf.readLine().trim());

			int p[] = new int[n+1];
			int i=1;
			
		    StringTokenizer st = new StringTokenizer(bf.readLine().trim());
		    while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    }
		    
		    boolean ret = true;
		    for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    }
		    
		    if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    }
		}catch(Exception e){
			e.printStackTrace();
		}
	
	}
} Main public static void main(String[] args) {
	
		try {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

			int n = Integer.parseInt(bf.readLine().trim());

			int p[] = new int[n+1];
			int i=1;
			
		    StringTokenizer st = new StringTokenizer(bf.readLine().trim());
		    while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    }
		    
		    boolean ret = true;
		    for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    }
		    
		    if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    }
		}catch(Exception e){
			e.printStackTrace();
		}
	
	} main {
	
		try {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

			int n = Integer.parseInt(bf.readLine().trim());

			int p[] = new int[n+1];
			int i=1;
			
		    StringTokenizer st = new StringTokenizer(bf.readLine().trim());
		    while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    }
		    
		    boolean ret = true;
		    for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    }
		    
		    if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    }
		}catch(Exception e){
			e.printStackTrace();
		}
	
	} try {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

			int n = Integer.parseInt(bf.readLine().trim());

			int p[] = new int[n+1];
			int i=1;
			
		    StringTokenizer st = new StringTokenizer(bf.readLine().trim());
		    while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    }
		    
		    boolean ret = true;
		    for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    }
		    
		    if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    }
		}catch(Exception e){
			e.printStackTrace();
		} catch(Exception e){
			e.printStackTrace();
		} Exception e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

			int n = Integer.parseInt(bf.readLine().trim());

			int p[] = new int[n+1];
			int i=1;
			
		    StringTokenizer st = new StringTokenizer(bf.readLine().trim());
		    while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    }
		    
		    boolean ret = true;
		    for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    }
		    
		    if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    }
		} BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(bf.readLine().trim()); n Integer.parseInt(bf.readLine().trim()) Integer.parseInt Integer bf.readLine().trim() bf.readLine().trim bf.readLine() bf.readLine bf int p[] = new int[n+1]; p new int[n+1] n+1 n 1 int i=1; i 1 StringTokenizer st = new StringTokenizer(bf.readLine().trim()); st new StringTokenizer(bf.readLine().trim()) while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    } st.hasMoreTokens() st.hasMoreTokens st {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    } p[i] = Integer.parseInt(st.nextToken()) p[i] p i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st i++ i boolean ret = true; ret true for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    } i=n; i=n i n i>1 i 1 i-- i-- i {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    } {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    } if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	} p[i-1] <=p[i] p[i-1] p i-1 i 1 p[i] p i {
		    		continue;
		    	} continue; if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	} p[i-1]-1 == p[i] p[i-1]-1 p[i-1] p i-1 i 1 1 p[i] p i {
		    		p[i-1]--;
		    	} p[i-1]-- p[i-1] p i-1 i 1 {
		    		ret = false;
		    		break;
		    	} ret = false ret false break; if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    } ret {
		    	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 class Main {
	public static void main(String[] args) {
	
		try {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

			int n = Integer.parseInt(bf.readLine().trim());

			int p[] = new int[n+1];
			int i=1;
			
		    StringTokenizer st = new StringTokenizer(bf.readLine().trim());
		    while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    }
		    
		    boolean ret = true;
		    for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    }
		    
		    if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    }
		}catch(Exception e){
			e.printStackTrace();
		}
	
	}
} public class Main {
	public static void main(String[] args) {
	
		try {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

			int n = Integer.parseInt(bf.readLine().trim());

			int p[] = new int[n+1];
			int i=1;
			
		    StringTokenizer st = new StringTokenizer(bf.readLine().trim());
		    while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    }
		    
		    boolean ret = true;
		    for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    }
		    
		    if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    }
		}catch(Exception e){
			e.printStackTrace();
		}
	
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
	
		try {
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

			int n = Integer.parseInt(bf.readLine().trim());

			int p[] = new int[n+1];
			int i=1;
			
		    StringTokenizer st = new StringTokenizer(bf.readLine().trim());
		    while (st.hasMoreTokens()) {
		    	p[i] = Integer.parseInt(st.nextToken());
		    	i++;
		    }
		    
		    boolean ret = true;
		    for(i=n;i>1;i--) {
		    	if (p[i-1] <=p[i]) {
		    		continue;
		    	}else if (p[i-1]-1 == p[i]) {
		    		p[i-1]--;
		    	}else {
		    		ret = false;
		    		break;
		    	}
		    }
		    
		    if ( ret  ) {
		    	System.out.println("Yes");
		    }else{
		    	System.out.println("No");
		    }
		}catch(Exception e){
			e.printStackTrace();
		}
	
	}
}