jiahuimbzuai/CoQuIR huggingface dataset:
//  [go]
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var panels []int
	var a, b, c int
	_, err := fmt.Scanf("%d %d %d", &a, &b, &c)
	if err != nil {
		fmt.Println(err)
	}

	panels = append(panels, a)
	panels = append(panels, b)
	panels = append(panels, c)

	for i := 0; i < len(panels); i++ {
		max := i
		for j := i + 1; j < len(panels); j++ {
			if panels[max] < panels[j] {
				max = j
			}
		}
		if i != max {
			tmp := panels[max]
			panels[max] = panels[i]
			panels[i] = tmp
		}
	}

	d := strconv.Itoa(panels[0])
	e := strconv.Itoa(panels[1])
	f, _ := strconv.Atoi(d + e)
	sum := f + panels[2]
	fmt.Println(sum)
}
//  [go]
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var panels []int
	var a, b, c int
	_, err := fmt.Scanf("%d %d %d", &a, &b, &c)
	if err != nil {
		fmt.Println(err)
	}

	panels = append(panels, a)
	panels = append(panels, b)
	panels = append(panels, c)

	for i := 0; i < len(panels); i++ {
		max := i
		for j := i + 1; j < len(panels); j++ {
			if panels[max] < panels[j] {
				max = j
			}
		}
		if i != max {
			tmp := panels[max]
			panels[max] = panels[i]
			panels[i] = tmp
		}
	}

	d := strconv.Itoa(panels[0])
	e := strconv.Itoa(panels[1])
	f, _ := strconv.Atoi(d + e)
	sum := f + panels[2]
	fmt.Println(sum)
//  [go]
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {
	n := nextInt()
	k := nextInt()
	s := nextInt()
	
	
	if (n >= k || n >= s) {
		Println(n*10 + k+s)
	}else if(k >= s || k >= n ){
		Println(k *10 + k+s)
	}else {
		Println(s* 10 + k+n)
	}
	
}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}
//  [go]
package main


func main(){
	var A,B,C int
	fmt.Scan(&A,&B,&C)
	if A >= B && A >= C{
		fmt.Println(10*A + B + C)
	}else if B >= A && B >= C{
		fmt.Println(10*B + A + C)
	}else{
		fmt.Println(10*C + A + B)
	}

}
//  [ruby]
s = gets.to_s.split.map{|t|t.to_i}.sort.reverse
ans = s[0] * 10 + s[1] + s[2]
puts ans
//  [ruby]
a=gets.split.map(&:to_i).sort
b=("#{a[2]}" + "#{a[1]}")
p b.to_i + a[0]
//  [ruby]
ls = (gets.chomp.split.map(&:to_i)).sort().reverse()
puts ls[0] * 10 + ls[1] + ls[2]
//  [ruby]
a=gets.chomp
b=gets.chomp
puts a==b.tr(a.tr(a,b),a)?:Yes: :No
//  [ruby]
a, b, c = gets.split.map(&:to_i)
x = a * 10 + b + c
y = a + b * 10 + c

puts [x,y].max
//  [ruby]
a, b, c = gets.chomp.split.map(&:to_i)
puts [10 * a + b + c, 10 * b + a + c].max
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let x = a * 10 + b + c;
    let y = a + b * 10 + c;
    let z = a + b + c * 10;
    println!("{}", max(x, max(y, z)));
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
    }
    let mut v = vec![a,b,c];
    v.sort();
    println!("{}", v[2] * 10 + v[1] + v[0]);
}
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter:Vec<&str> = buf.split_whitespace().collect();
	let mut s:Vec<String> = Vec::new();
	for i in 0..3 {
		s.push(iter[i].to_string());
	}
	s.sort();
	let x = s[2].parse::<i32>().ok().unwrap() * 10 + s[1].parse::<i32>().ok().unwrap();
	let y = s[0].parse::<i32>().ok().unwrap();
	println!("{}", x+y);
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let x = a * 10 + b + c;
    let y = a + b * 10 + c;
    let z = a + b + c * 10;
    println!("{}", max(a, max(b, c)));
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let x = a * 10 + b + c;
    let y = a + b * 10 + c;
    println!("{}", if x > y { x } else { y })
}
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}.sort(>)
print(input[0]*10 + input[1] + input[2])
//  [swift]
func main() {
  let abc = readLine()!.split(separator: " ").map{Int($0)!}
  let result = abc.max()! * 10 + abc.reduce(0, +) - abc.max()!
  print(result)
}

main()
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))}.sort(>)
print(input[0]*10 + input[1] + input[2])
//  [swift]
let input = readLine()!.characters.split(" ").map{Int($0)}.sort(>)
print(input[0]*10 + input[1] + input[2])
//  [swift]
let input = readLine.characters.split(" ").map{Int($0)}.sort(>)
print(input[0]*10 + input[1] + input[2])
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.abc110 {

    class Program {
        /**
         * in
         *  1 5 2
         * out
         *  53
         */
        main(inp: string): void {
            const abc: number[] = inp.split(' ').map(Number);
            const abcSorted:number[] = abc.sort((a, b) => b - a);

            const x: string = abcSorted.slice(0, 2).join('');
            const y: string = abcSorted.slice(2).join('');

            console.log(parseInt(x) + parseInt(y));
        }
    }

    const prg = new Program();
    prg.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}
//  [typescript]

	const process = (a: string[]): number => {
		const aa = a.map((e) => parseInt(e))
		if (aa[0] >= aa[1] && aa[0] >= aa[2]) {
			return aa[0] * 10 + aa[1] + aa[2]
		}
		if (aa[1] >= aa[0] && aa[1] >= aa[2]) {
			return aa[0] + aa[1] * 10 + aa[2]
		}
		if (aa[2] >= aa[0] && aa[2] >= aa[1]) {
			return aa[0] + aa[1] + aa[2] * 10
		}
	}

	const Main = (input: string): void => {
		//const n: number = parseInt(input)
		const a: string[]  = input.split(" ")
		//const aa: string[][]  = input.split("\n").split(" ")
		const answer = process(a)
		console.log(answer)
	}

	/*
	// デバッグ用
	Main("1 5 2") // 53
	console.log()

	Main("9 9 9") // 108
	console.log()

	Main("6 6 7") // 82
	*/

	// 提出時はこちらをアクティブにする
	Main(require("fs").readFileSync("/dev/stdin", "utf8"))
}
//  [typescript]
var int = x=>parseInt(x,10);var spln = x=>x.split(/\n/g);var spsp = x=>x.split(/\s/g);
function main(input) {
  var a = input.split(/\n|\s/g).map((v)=>parseInt(v,10)).slice(0,3).sort()
  console.log(a[2]*10+a[1]+a[0])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
{
	const process = (a: string[]): number => {
		const aa = a.map((e) => parseInt(e))
		// aa[0] が最大
		if (aa[0] >= aa[1] && aa[1] >= aa[2]) {
			return aa[0] * 10 + aa[1] + aa[2]
		}
		if (aa[1] >= aa[0] && aa[1] >= aa[2]) {
			return aa[0] + aa[1] * 10 + aa[2]
		}
		if (aa[2] >= aa[0] && aa[1] >= aa[1]) {
			return aa[0] + aa[1] + aa[2] * 10
		}
	}

	const Main = (input: string): void => {
		//const n: number = parseInt(input)
		const a: string[]  = input.split(" ")
		//const aa: string[][]  = input.split("\n").split(" ")
		const answer = process(a)
		console.log(answer)
	}

	/*
	// デバッグ用
	Main("1 5 2") // 53
	console.log()

	Main("9 9 9") // 108
	console.log()

	Main("6 6 7") // 82
	*/

	// 提出時はこちらをアクティブにする
	Main(require("fs").readFileSync("/dev/stdin", "utf8"))
}
//  [python]
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    h_ls = tuple(map(int, input().split()))
    h_ = h_ls[-1]

    for h in h_ls[-2::-1]:
        if h > h_:
            if h - 1 == h_:
                continue
            print('No')
            quit()
        h_ = h
    print('Yes')


if __name__ == '__main__':
    main()
//  [python]
def main():
    H = map(int, open(0).read().split()[:0:-1])
    pre = None
    for h in H:
        if pre is None:
            pre = h
        elif h <= pre:
            pre = h
        elif pre + 1 == h:
            continue
        else:
            # pre + 1 < h
            print("No")
            return

    print("Yes")
    return


main()
//  [python]
def main():
    H = map(int, open(0).read().split()[:1:-1])
    pre = None
    for h in H:
        if pre is None:
            pre = h
        elif h <= pre:
            pre = h
        elif pre + 1 == h:
            continue
        else:
            # pre + 1 < h
            print("No")
            return

    print("Yes")
    return


main()
//  [python]
from collections import Counter
import math
import statistics
import itertools
# a,b=map(int,input().split())
b=int(input())
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
#g = [list(map(lambda x: '{}'.format(x), list(input()))) for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
# lis=[input() for i in range(a)]

lis = list(map(int,input().split()))
ans=lis[0]
seigi=lis
word=""
for i in range(1,b):
    word=lis[i]
    if ans<=word:
        ans=word
        word=""
    else:
        if ans-1 == word :
            ans=word
            seigi[i-1]-=1
            word=""

for i in range(b-1):
    if seigi[i] > seigi[i+1]:
        print("No")
        exit()

print("Yes")
//  [python]
from collections import Counter
import math
import statistics
import itertools
# a,b=map(int,input().split())
b=int(input())
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
#g = [list(map(lambda x: '{}'.format(x), list(input()))) for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
# lis=[input() for i in range(a)]

lis = list(map(int,input().split()))
ans=lis[0]
seigi=lis
word=""
for i in range(1,b):
    word=lis[i]
    if ans<=word:
        ans=word
        word=""
    else:
        if ans-1 == word :
            ans=word
            seigi[i-1]-=1
            word=""
seigi2=sorted(seigi)
if seigi2==seigi:
    print("Yes")
else:
    print("No")
//  [python]
n = int(input())
h = list(map(int, input().split()))

if n == 1:
    print("Yes")
elif n == 2:
    if h[0] - h[1] <= 1:
        print("Yes")
    else:
        print("No")
else:
    c = 0
    if h[0] - h[1] == 1:
        h[0] -= 1
        for i in range(1, n-1):
            if h[i] - h[i+1] == 1 and h[i-1] != h[i]:
                h[i] -= 1
                c += 1
            elif h[i] <= h[i+1]:
                c += 1
            else:
                break
    elif h[0] <= h[1]:
        for i in range(1, n-1):
            if h[i] - h[i+1] == 1 and h[i-1] != h[i]:
                h[i] -= 1
                c += 1
            elif h[i] <= h[i+1]:
                c += 1
            else:
                break    

    if c == n-2:
        print("Yes")
    else:
        print("No")
//  [java]
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int n = ni();
		int[] a = na(n);
		if(n == 1) {
			out.println("Yes");
			return;
		}
		for(int i = n-2; i >= 0; i--) {
			if(a[i] <= a[i+1]) continue;
			a[i]--;
			if(a[i] > a[i+1]) {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
	}
			    
	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private float nf() {
		return Float.parseFloat(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] H = new int[N];
            for (int i = 0; i < N; i++) {
                H[i] = in.nextInt();
            }

            for (int i = 1; i < N; i++) {
                if (H[i - 1] - 1 > H[i]) {
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
        }
    }
}
//  [java]
Yes
//  [cpp]
//#include<bits/stdc++.h>
#include<cstdio>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	
	int ikeru = 1;
	int h = -1;
	rep(i, N) {
		int H = getint();
		if (H > h) h = H - 1;
		else if (H < h) ikeru = 0;
	}
	
	if (ikeru) printf("Yes");
	else printf("No");

	Would you please return 0;
}
//  [cpp]
#include<cstdio>
 
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please
 
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
 
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
 
 
	int N = getint();
	
	int ikeru = 1;
	int h = -1;
	rep(i, N) {
		int H = getint();
		if (H > h) h = H - 1;
		else if (H < h) ikeru = 0;
	}
	
	if (ikeru) printf("Yes");
	else printf("No");
 
	Would you please return 0;
}
//  [cpp]
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> h(n);
    cin >> h;
    bool ok = true;
    int now = h[n-1];
    for(int i = n-1;i>0;i--){
        if(now>=h[i-1]-1){
            now = max(now,h[i-1]-1);
        }
        else{
            ok = false;
        }
        
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	long long int i,h[n];
	for(i=0;i<n;i++)
	{
		cin>>h[i];
	}
	for(i=1;i<n;i++)
	{
		if(h[i]-h[i-1]<-1)
		{
			cout<<"No"<<endl;
			return 0;
		}
		if(h[i]<h[i-1] && h[i]>h[i+1])
		{
		 if(i+1<=n-1)
		 {
			cout<<"No"<<endl;
			return 0;
		 }
		}
	}
	cout<<"Yes"<<endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	long long int i,h[n];
	for(i=0;i<n;i++)
	{
		cin>>h[i];
	}
	for(i=1;i<n;i++)
	{
		if(h[i]-h[i-1]<-1)
		{
			cout<<"No"<<endl;
			return 0;
		}
		if(h[i]<h[i-1] && h[i]>h[i+1])
		{
		 if(i+1<=n-1)
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}
//  [c]
// AtCoder ABC136: C - Build Stairs
// 2019.8.26 bal4u

#include <stdio.h>

//// 高速入力
#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int main()
{
	int h, ph, N;
	
	ph = 0;
	N = in(); while (N--) {
		h = in();
		if (ph < h) h--;
		if (ph > h) { puts("No"); return 0; }
		ph = h;
	}
	puts("Yes");
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N,i;
  long h[100005];
  char str[2000000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  h[0]=atol(p);
  
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
  	h[i]=atol(p);
  }
  
  h[0]-=1;
  
  for(i=1;i<N;i++){
    if(h[i-1]>h[i]){
      printf("No\n");
      return 0;
    }
    if(h[i-1]<h[i]){
      h[i]-=1;
    }
  }
  
  printf("Yes\n");
  
  return 0;
}
//  [c]
#include<stdio.h>

int main(){
    int n;
    int i;
    int num;
    char *tmp = NULL;
    int max=0,min=0;
    char ch;

    while(~scanf("%d",&n)){
        getchar();
        int no = 0;
        num = 0;
        max = min = 0;
        while((ch = getchar())){
            if(ch == ' '||ch == '\n'){
                if(num > max){
                    max = min = num;
                }else if(num < min){
                    min = num;
                }

                if(max - min > 1){
                    no = 1;
                }
                num = 0;
                if(ch == '\n') break;
            }else{
                num=num*10+ (ch - '0');
            }
        }

        printf("%s\n",no?"No":"Yes");
    }
    return 0;
}
//  [c]
#include <stdio.h>

int main(void){
  int n,a[100005],i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }
  for(i=n-1;i>=1;i--){
    if(a[i]<a[i-1]){a[i-1]--;
    printf("No");return 0;}
  }
  i=n-2;
  if(a[i]<a[i-1]){ printf("No");return 0;}

  printf("Yes\n");

  return 0;
}
//  [c]
#include <stdio.h>

int main(void){
  int n,a[100005],i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }
  for(i=n-1;i>=1;i--){
    if(a[i]<a[i-1])a[i-1]--;
    if(a[i]<a[i-1]){printf("No");return 0;}
  }
  printf("Yes\n");

  return 0;
}
//  [c]
#include <stdio.h>

int main(void){
  int n,h[100005],i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&h[i]);
  }
  for(i=1;i<=n-2;i++){
    if((i==n-2)&&(h[i]-h[i+1]>=2)){
      printf("No\n");
      return 0;
        }else{
    if((h[i]-h[i+1]>=2)&&(h[i]<=h[i+2])){
    printf("No\n");
      return 0;

    }else if(h[i]-h[i+1]==1){
    h[i]--;
    }
    }

  printf("Yes\n");

  return 0;
  }
}
//  [javascript]
function f(inp) {
    inp = inp.split("\n");
    var N = +inp[0];
    for (var i = 0, H = inp[1].split(" "); i < H.length;) {
        H[i] = +H[i++];
    }
    var lf = H[0];
    for (var i = 1; i < N; i++) {
        if (lf < H[i]) {
            H[i]--;
        }
        else if (lf > H[i]) {
            console.log("No");
            return;
        }
        lf = H[i];
    }
    console.log("Yes");
}
f(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  var len = parseInt(input.split("\n")[0]);
  var list = input.split("\n")[1].split(" ");
  if(len == 1){
     console.log("Yes");
    return;
  }else{
      for(var i = 0; i < list.length - 1; i++){
        var tmp1 = parseInt(list[i]);
        var tmp2 = parseInt(list[i + 1]);
        var tmp3 = tmp2 - 1;
        //console.log(tmp1 + "," + tmp2 + "," + tmp3);
        if(tmp1 <= tmp2 || tmp1 <= tmp3){
           if(tmp1 <= tmp3){
              list[i + 1] = tmp3;
           }
        }else{
           console.log("No");
        return;
        }
      }
    console.log("Yes");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // tmp0 = input[0].split(" ");
    tmp1 = input[1].split(" ");
    N = Number(input[0])
    H = []
    for(var i=0; i < N; i++)
    {
      H.push(Number(tmp1[i]))
    }

    beforeH = H[0]

    for(var i=1; i < N; i++)
    {
      if(beforeH < H[i])
      {
        H[i]--
      }
      else if(beforeH > H[i])
      {
        console.log("No")
        return;
      }
      beforeH = H[i]
    }
    console.log("Yes")
}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("5\n1 2 1 1 3\n");
//  [javascript]
function f(inp) {
    inp = inp.split("\n");
    var N = +inp[0];
    var H = inp[1].split(" ").map(s => +s);
    var lf = H[0];
    for (var i = 1; i < N; i++) {
        var x = H[i];
        if (lf < x) {
            H[i]--;
        }
        else if (lf > x) {
            console.log("No")
            return;
        }
        lf = x;
    }
    console.log("Yes")
}
f(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]


function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var H = input[1].split(" ").map(i => parseInt(i));
  var H1=0;
  var ans="Yes";
  var max=0;
  for(var i=1;i<N;i++){
    if(H[i-1]-H[i]>2){
      ans="No";
      break;
    }else if(H[i-1]-H[i]==1){
      if(H[i-1]-1>=max){
        max=H[i-1]-1;
      }else{
        ans="No";
        break;
      }
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
<!DOCTYPE html>
<html lang="ja">

<head>
  <script src="main.js"></script>
</head>

<body>

Input1:<br />
<textarea id="input1" rows="5" cols="80">4
1 3 2 1
  
</textarea><br />
<input type="button" value="実行する" onClick="debug(1);"><br />
<textarea id="output1">No</textarea><br />
<div id="result1"> </div><br />

Input2:<br />
<textarea id="input2" rows="5" cols="80">5
1 2 3 4 5
  
</textarea><br />
<input type="button" value="実行する" onClick="debug(2);"><br />
<textarea id="output2">Yes</textarea><br />
<div id="result2"> </div><br />

Input3:<br />
<textarea id="input3" rows="5" cols="80">5
1 2 1 1 3

</textarea><br />
<input type="button" value="実行する" onClick="debug(3);"><br />
<textarea id="output3">Yes</textarea><br />
<div id="result3"> </div><br />

Input4:<br />
<textarea id="input4" rows="5" cols="80">

</textarea><br />
<input type="button" value="実行する" onClick="debug(4);"><br />
<textarea id="output4"></textarea><br />
<div id="result4"> </div><br />

</body>
</html>
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = ri()
	}

	prev := -1
	ok := true
	for _, now := range h {
		// fmt.Println(prev, now)
		if prev <= now {
			if now > prev {
				now--
			}
			prev = now
			continue
		} else {
			ok = false
			break
		}
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = ri()
	}

	ok := true
	prev := -1
	for _, now := range h {
		if prev > now {
			ok = false
			break
		} else if prev < now {
			now--
		}
		prev = now
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = ri()
	}

	h = append([]int{-1}, h...)
	ok := true
	for i := 1; i < len(h); i++ {
		switch {
		case h[i-1] > h[i]:
			ok = false
			break
		case h[i-1] < h[i]:
			h[i]--
		}
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [ruby]
N = gets.to_i
H = gets.split.map(&:to_i)
result = "Yes"
top = H[-1]
H.reverse.each do |h|
  if h <= top
    top = h
  else
    if h-1 == top
      next
    else
      result = "No"
      break
    end
  end
end
puts result
//  [ruby]
N = gets.to_i
H = gets.split.map(&:to_i)

max = H[-1]
satisfied = true
H[0..-1].reverse.each do |h|
  if h <= max
    max = h
  else
    if h - 1 == max
      next
    else
      satisfied = false
      break
    end
  end
end

if satisfied
  puts 'Yes'
else
  puts 'No'
end
//  [ruby]
N = gets.to_i
heights = gets.split.map(&:to_i)
answer = true
previous = heights.shift
heights.each do |current|
  if previous < current
    # OKなパターン
    # 念の為、一つ下げておく（下げてもpreviousと同じかそれより上）
    previous = current - 1
  elsif previous == current
    # これもOKなパターン。
    #　高さはpreviousのまま。
  elsif previous == current - 1
    # 1減らして同じ高さになったパターン
    # この場合には高さはpreviousのまま
  else # previous > current - 1
    # Failedパターン
    answer = false
    break
  end
end
puts answer ? "Yes" : "No"
//  [ruby]
n = gets.to_i
num = gets.strip.split.map(&:to_i)
if n==1
  puts "Yes"
  exit
end
s = 1
i = 0
while i < n-1 do
  if num[i]==num[i+1]+1
    num[i] -= 1
  elsif num[i]>num[i+1]+1
    s = 0
    break
  end
  i += 1
end
if s==0
  puts "No"
else
  if num.sort == num
    puts "Yes"
  else
    puts "No"
  end
end
//  [ruby]
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
down_flag = 0
for i in 0..(n-2)
  if arr[i] > arr[i+1] + 1
    puts "No"
    exit
  elsif arr[i] == arr[i+1] + 1
    if down_flag == 1
      puts "No"
      exit
    else
      down_flag = 1
    end
  elsif arr[i] <= arr[i+1]
    down_flag = 0
  end
end
puts "Yes"
//  [ruby]
n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)
i = 1
while true
    if n == 1
        puts "Yes"
        exit
       end
   if  h[i-1] -1 > h[i]
     puts "No"
     exit
   end
   i += 1
   if i == h.size
    puts "Yes"
    exit
   end
end
//  [rust]
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut hv = vec![0i32; n];
    for i in 0..n - 1 {
        hv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    hv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = true;
    let mut p = hv[0];
    for i in 0..n {
        if hv[i] == p {
            continue;
        } else if hv[i] > p {
            p = hv[i] - 1;
        } else {
            ans = false;
            break;
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}
//  [rust]
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    let mut v = input_vector::<usize>();
    let mut flag = true;
    let mut prev = 0;

    for z in &mut v {
        if prev < *z {
            *z -= 1;
        }
        if prev > *z {
            flag = false;
            break;
        }
        prev = *z;
    }
    if flag {
        p("Yes");
    } else {
        p("No");
    }
}
//  [rust]
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut v:Vec<u128> = (0..n).map(|_| read()).collect();
    let mut mx = v[0];
    let mut ans = "Yes";
    for i in 1..n {
        if v[i] < v[i-1] {
            v[i-1] -= 1;
        }
        mx = max(mx, v[i-1]);
        if v[i] < mx {
            ans = "No";
            break;
        }
    }
    println!("{}", ans);
}
//  [rust]
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut v:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut mx = v[0];
    let mut ans = "Yes";
    for i in 1..n {
        if v[i] < v[i-1] {
            v[i-1] -= 1;
        }
        mx = max(mx, v[i-1]);
        if v[i] < mx {
            ans = "No";
            break;
        }
    }
    println!("{}", ans);
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut v:Vec<usize> = (0..n).map(|_| read()).collect();
    for i in 1..n {
        if v[i] < v[i-1] {
            v[i-1] -= 1;
        }
    }
    let mut c = v.clone();
    c.sort();
    if c == v {
        println!("Yes");
    } else {
        println!("No");
    }
}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var aryH = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    aryH.reverse()
    
    for i in 1..<n {
        if aryH[i - 1] < aryH[i] {
            aryH[i] -= 1
            if aryH[i - 1] < aryH[i] {
                print("No")
                return
            }
        }
    }
    print("Yes")
    
}
main()
//  [swift]
import Foundation
import CoreFoundation

#if swift(>=4.0)
#else
extension String {
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map{String($0)}
    }
    var count: Int {
        return self.characters.count
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    mutating func swapAt(i: Int, _ j: Int) {
        swap(&self[i], &self[j])
    }
    func joined(separator separator: String = " ") -> String {
        return self.map{String($0)}.joinWithSeparator(separator)
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func reverse() {
        self = self.reversed()
    }
    func enumerated() -> EnumerateSequence<[Element]> {
        return self.enumerate()
    }
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: Character = " ") -> [String] {
    return readLine()!.split(separator: separator)
}
func readIntSplit(by separator: Character = " ") -> [Int] {
    return readLine()!.split(separator: separator).map{Int($0)!}
}
prefix operator * { }
prefix func * <T> (a: [T]) -> (T, T)          { return (a[0], a[1]) }
prefix func * <T> (a: [T]) -> (T, T, T)       { return (a[0], a[1], a[2]) }
prefix func * <T> (a: [T]) -> (T, T, T, T)    { return (a[0], a[1], a[2], a[3]) }
prefix func * <T> (a: [T]) -> (T, T, T, T, T) { return (a[0], a[1], a[2], a[3], a[4]) }
infix operator ** { associativity right precedence 155 }    // 右結合，乗除算より強くビットシフトより弱い
func **(lhs: Int, rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
func **(lhs: Int, rhs: Double) -> Double {
    return pow(Double(lhs), rhs)
}
//func gcd(x: Int, _ y: Int) -> Int {
//    return y>0 ? gcd(y, x%y) : x
//}
//func lcm(x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}
let MOD = 10**9+7

/*************** テストスペース ***************/

//arr.sort{$0.0==$1.0 ? $0.1<$1.1 : $0.0<$1.0}  // タプル配列のソート

/*************** メインプログラム ***************/

let N = readInt()!
var H = readIntSplit()
for i in (0..<N-1).reverse() {
    if H[i] > H[i+1] {
        H[i] -= 1
    }
}
var ans = "Yes"
for i in 0..<N-1 {
    if H[i] > H[i+1] {
        ans = "No"
        break
    }
}
print(ans)
//  [swift]
let range = (0..<Int(readLine()!)!-1).reverse()
var H = readLine()!.characters.split(" ").map{Int(String($0))!}
for i in range {
    if H[i] > H[i+1] {
        H[i] -= 1
    }
}
var ans = "Yes"
for i in range {
    if H[i] > H[i+1] {
        ans = "No"
    }
}
print(ans)
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var aryH = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    aryH.reverse()
    print(aryH)
    
    for i in 1..<n {
        if aryH[i - 1] < aryH[i] {
            aryH[i] -= 1
            if aryH[i - 1] < aryH[i] {
                print("No")
                return
            }
        }
    }
    print("Yes")
    
}
main()
//  [swift]
let n=Int(readLine()!)!
var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var i = 0
var p = arr[0]
var ret : String = ""
for i in 1..<n {
  let d = arr[i] - arr[i - 1]
  if(  d < -1 ) {
    break
  } else if( d < 0 ) {
    arr[i - 1] -= 1
  }
}

for i in 1..<n {
  if( arr[i] < arr[i - 1] ) {
    ret = "No"
    break
  }
}

if( ret == "" ) {
  print( "Yes" )
} else {
  print( "No" )
}