qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    def c(n):
        if n == 1:
            return 0
        else:
            return n * (n - 1) // 2


    N = int(lines.pop(0))
    NLIST = {}
    for i in range(N):
        l = ''.join(sorted(lines.pop(0)))
        print(l)
        if l in NLIST:
            NLIST[l] += 1
        else:
            NLIST[l] = 1

    re = 0
    for n in NLIST.values():
        re += c(n)
    print(re)
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

# Fixed code:
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    def c(n):
        if n == 1:
            return 0
        else:
            return n * (n - 1) // 2


    N = int(lines.pop(0))
    NLIST = {}
    for i in range(N):
        l = ''.join(sorted(lines.pop(0)))
        if l in NLIST:
            NLIST[l] += 1
        else:
            NLIST[l] = 1

    re = 0
    for n in NLIST.values():
        re += c(n)
    print(re)
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)
# Buggy code:
import math
import _collections
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N=int(input())
strings=[str(sorted(input())) for a in range(N)]
c=_collections.Counter(strings)
tp=c.most_common()
sums=0
for thing in tp:
    if tp[1]!=1:
        sums=sums+combinations_count(tp[1],2)
    else:break
    
print(sums)

# Fixed code:
import math
import collections
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N=int(input())
strings=[str(sorted(input())) for a in range(N)]
c=collections.Counter(strings)
tp=c.most_common()
sums=0
for thing in tp:
    if thing[1]!=1:
        sums=sums+combinations_count(thing[1],2)
    else:break

print(sums)
# Buggy code:
from collections import Counter


def main():
    n = int(input())
    cnt = Counter()
    ans = 0
    for i in range(n):
        s = sorted(input())

        if cnt[s] == 0:
            cnt[s] = 1
        else:
            ans += cnt[s]
            cnt[s] += 1
    print(ans)


if __name__ == "__main__":
    main()


# Fixed code:
from collections import Counter


def main():
    n = int(input())
    cnt = Counter()
    ans = 0
    for i in range(n):
        s = "".join(sorted(input()))
        if cnt[s] == 0:
            cnt[s] = 1
        else:
            ans += cnt[s]
            cnt[s] += 1
    print(ans)


if __name__ == "__main__":
    main()
# Buggy code:
n=int(input())
l=[]
for i in range(n):
  w=list(input())
  l.append(w)
l=sorted(l)
c=0
c1=0
w1=l[0]
for i in range(n):
  if w1==l[i]:
    c1+=0
  else:
    c+=c1*(c1-1)//2
    c1=1
c+=c1*(c1-1)//2
print(c)


# Fixed code:
n=int(input())
l=[]
for i in range(n):
  w=sorted(list(input()))
  l.append(w)
l=sorted(l)
c=0
c1=0
w1=l[0]
for i in range(n):
  if w1==l[i]:
    c1+=1
  else:
    w1=l[i]
    c+=c1*(c1-1)//2
    c1=1
    
c+=c1*(c1-1)//2
print(c)
# Buggy code:
from collections import Counter
n = int(input())
s = [str(sorted(input())) for i in range(n)]
print(s)
c = Counter(s)
print(c)
l = sum((v*(v-1)/2) for v in c.values())
print(l)

# Fixed code:
from collections import Counter
n = int(input())
s = [str(sorted(input())) for i in range(n)]

c = Counter(s)

l = sum((v*(v-1)/2) for v in c.values())
print(int(l))
# Buggy code:
a, b, c = (int(i) for i in input().split())
print(max(0, c - (b - c)))

# Fixed code:
a,b,c = (int(i) for i in input().split())
ans = max(c-(a-b),0)
print(ans)
# Buggy code:
a = list(map(int,input().split()))
print(a[2]-(a[0]-a[1]))


# Fixed code:
a = list(map(int,input().split()))
print(max(a[2]-(a[0]-a[1]),0))
# Buggy code:
a,b,c = list(map(int, input().split()))
d = c-(a-b)
if d >= 0:
  print(d)
else if:
  print(0)


# Fixed code:
a,b,c=map(int,input().split())
a=a-b
if a>=c:
    print(0)
else:
    print(c-a)
# Buggy code:
a,b,c = map(int,input().split())
print(max(0,b+c-a)

# Fixed code:

a, b, c = map(int, input().split())
print(max(0, c-a+b))
# Buggy code:
print(max(0,eval('-'+input().replace(' ','+')))

# Fixed code:
print(max(0,eval('-'+input().replace(*' +'))))
# Buggy code:
a,b,c = map(int,input().split())

print(max(c-(a-b),0)

# Fixed code:
a, b, c = map(int, input().split())
ato = a - b
print(max(0, c - ato))
# Buggy code:
a,b,c=map(int,input().split())
m=b-a
if m>=c:
    print(0)
else:
    print(c-m)

# Fixed code:
a,b,c=map(int, input().split())

if b + c - a > 0:
    print( b + c - a )
else:
    print(0)
# Buggy code:
array =  list(map(int, input().split(' ')))
a = array[0]
b = array[1]
c = array[2]

d = a-b

if d > c:
    print(c)
else:
    print(d-c)

# Fixed code:
array =  list(map(int, input().split(' ')))
a = array[0]
b = array[1]
c = array[2]

d = a-b

if (c - d) < 0:
    print(0)
else:
    print(c-d)
# Buggy code:
a, b, c = map(int,input().split())
d = c - (a - b)
if d >= 0:
    print(d)

# Fixed code:
a, b, c = map(int,input().split())
d = c - (a - b)
if d >= 0:
    print(d)
else:
    print(0)
# Buggy code:
A,B,C = map(int,input().split())
if C >= A + B:
    print(C-A+B)
else:
    print(0)

# Fixed code:
A, B, C = map(int, input().split())

if C >= (A-B):
    print(C-(A-B))
else:
    print(0)
# Buggy code:
a,b,c = map(int,input().split())
if(b+c >= a):
print(b+c-a)
else:
  print(0)

# Fixed code:
def main():
    a,b,c = map(int,input().split())
    if a-b >= c:
        print(0)
    else:
        print(c-a+b)

main()
# Buggy code:
A,B,C= map(int, input().split())
if A<=B+C:
    print(0)
if A>B+C:
    print(B+C-A)

# Fixed code:
A,B,C= map(int, input().split())
if A>B+C:
    print(0)
if A<=B+C:
    print(B+C-A)
# Buggy code:
A,　B, C, = taple(map(int, input().split()))
if (A - B) >= C:
  	print(0)
else:
  	print(C - (A - B))

# Fixed code:
A, B, C = map(int, input().split())

accept = A - B
if C - accept > 0:
    print(C-accept)
else:
    print(0)
# Buggy code:
a, b, c = map(int,input().split())
print(max(c-a-b),0)

# Fixed code:
a,b,c = map(int,input().split())

print(max(0, c-(a-b)))
# Buggy code:
# coding: utf-8
# Your code here!
n=input().split(" ")
for i in range(3):
  n[i]=int(n[i])
ans=(n[2]-(n[1]-n[0])
if ans <0:
	print(0)
else:
     print(ans)
     


# Fixed code:
# coding: utf-8
# Your code here!
n=input().split(" ")
for i in range(3):
  n[i]=int(n[i])
ans=(n[2]-(n[0]-n[1]))
if ans < 0:
	print(0)
else:
     print(ans)
# Buggy code:
A, B, C = map(int, input().split())
if C < 0:
    print(0)
else:
    print(C - (A - B))

# Fixed code:
A, B, C = map(int, input().split())
if C - (A - B) < 0:
    print(0)
else:
    print(C - (A - B))
# Buggy code:
a,b,c=map(int,input().split())

print(a)

if a-b>=c:
  print(0)
else:
  print(c-a+b)

# Fixed code:
a, b, c = map(int, input().split())
result = b + c - a if b + c >= a else 0
print(result)
# Buggy code:
A, B, C = map(int, input().split())
print(max(C - (A - B)), 0)

# Fixed code:
A, B, C = map(int, input().split())
print(max(0, C - A + B))
# Buggy code:
a,b,c = map(int, input().split)
if c - (a -b) >= 0:
  print(c - (a -b))
else:
  print(0)


# Fixed code:
a,b,c = map(int,input().split())
if c-(a-b) >= 0:
    print(c-(a-b))
else:
    print(0)
# Buggy code:
A, B, C = map(int, input().split())
print(C - (A-B))

# Fixed code:
A,B,C=map(int,input().split())
print(C-min(C,A-B))
# Buggy code:
A, B, C= map(int, input().split())
if C < (A-B):
    print("0")
else  
    print(C-(A-B))

# Fixed code:
A, B, C= map(int, input().split())
if C < (A-B):
    print("0")
else:
    print(C-(A-B))
# Buggy code:
a,b,c = map(int,input().split())
q = a-b
ans = c - ans

if ans < 0:
  ans = 0
  
print(ans)

# Fixed code:
a,b,c = map(int,input().split())
q = a-b
ans = c-q

if ans < 0:
  ans = 0
  
print(ans)
# Buggy code:


    a,b,c=map(int,input().split())
    print(max(0,c-max(0,a-b)))

# Fixed code:
a, b, c=list(map(int,input().split()))
print(max(c-(a-b), 0))
# Buggy code:
a,b,c = map(int, input().split())
w = (b+c)-a
if w:
    w = 0
print (w)

# Fixed code:
a,b,c = map(int, input().split())
w = (b+c)-a
if w < 1:
    w = 0
print (w)
# Buggy code:
a,b,c=map(int,input().split())
if b+c>=a:
  print(0)
else:
  print(c-a+b)

# Fixed code:
a,b,c = map(int, input().split())
rest = c-(a-b)
if rest > 0:
	print(rest)
else:
	print(0)
# Buggy code:
a,b,c = map(int,input().split())
if a >= c :
    print(0)
else:
    print(c-a+b)

# Fixed code:
import sys

a,b,c=map(int, input().split())

if(a >= (b + c)):
    print(0)
else:
    print(c - (a - b))
# Buggy code:
a, b, c = map(int, input().split())

if a-b >= c-b:
    cup2 = 0

else:
    cup1 = abs(a - b) 
    cup2 = c - cup1

print(cup2)

# Fixed code:
a, b, c = map(int, input().split())

if a-b >= c:
    cup2 = 0

else: 
    cup2 = c - (a-b)

print(cup2)
# Buggy code:
a, b, c = map(int, input().split())
d = c - a - b
if d > 0:
  print(d)
else:
  print(0)

# Fixed code:
a,b,c = map(int,input().split())
d = c - a + b

if d>=0:
    print(d)

else:
    print(0)
# Buggy code:
a b c = list(map(int, input().split()))
d = c - (a - b)
if d > 0:
  print(d)
else:
  print(0)

# Fixed code:
a, b, c = list(map(int, input().split()))

tmp = c - (a - b)

if tmp > 0:
  print(tmp)
else:
  print(0)
# Buggy code:
def transfer(a, b, c):

    return b+c if a > b+c else a
def main():
    a, b, c = map(int, input().split())
    print(transfer(a, b, c))

if __name__ == '__main__':
    main()


# Fixed code:
def transfer(a, b, c):

    return 0 if a > b+c else c+b-a
def main():
    a, b, c = map(int, input().split())
    print(transfer(a, b, c))

if __name__ == '__main__':
    main()
# Buggy code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    H=LI()+[10**10]
    
    for i in range(N):
        if H[i]>=H[i+1]:
            H[i]-=1
            
    flag=1
    now=0
    for i in range(N):
        if H[i]<now:
            flag=0
            break
        now=H[i]
        
    if flag:
        print("Yes")
    else:
        print("No")
            

main()


# Fixed code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    H=LI()
    
    now=0
    
    for i in range(N):
        if H[i]!=now:
            H[i]-=1
        now=H[i]
    
    flag=1
    now=0
    for i in range(N):
        if H[i]<now:
            flag=0
            break
        now=H[i]
        
    if flag:
        print("Yes")
    else:
        print("No")
            

main()
# Buggy code:
N = int(input())

H = list(map(int, input().split()))

for i in range(N):
    if i == 0:
        H[i] -= 1
        continue

    if i == N - 1:
        if H[i] < H[i - 1]:
            print('No')
            exit()
        else:
            break

    if H[i + 1] - H[i] <= -2:
        print('No')
        exit()

    if H[i + 1] - H[i] <= 0:
        if H[i] > H[i - 1]:
            H[i] -= 1
    elif H[i] < H[i + 1]:
        H[i] -= 1

    if H[i] < H[i - 1]:
        print('No')
        exit()

print('Yes')

# Fixed code:
N = int(input())

H = list(map(int, input().split()))

for i in range(N):
    if i == 0:
        H[i] -= 1
        continue

    if i == N - 1:
        if H[i] < H[i - 1]:
            print('No')
            exit()
        else:
            break

    if H[i + 1] - H[i] <= -2:
        print('No')
        exit()

    if H[i + 1] - H[i] <= 0:
        if H[i] > H[i - 1]:
            H[i] -= 1
    elif H[i] < H[i + 1] and H[i - 1] < H[i]:
        H[i] -= 1

    if H[i] < H[i - 1]:
        print('No')
        exit()

print('Yes')
# Buggy code:
import sys
n = int(input())
h = list(map(int,input().split()))
h.sort(reverse=True)

for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1
        
ans = 'Yes'
for j in range(n-1):
    if h[j] < h[j+1]:
        print('No')
        sys.exit()
print(ans)

# Fixed code:
import sys
n = int(input())
h = list(map(int,input().split()))
h = h[::-1]

for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1

ans = 'Yes'
for j in range(n-1):
    if h[j] < h[j+1]:
        print('No')
        sys.exit()

print(ans)
# Buggy code:
def main():
    n = int(input())
    h = list(map(int, input().split()))
    
    pre = h[0]
    for hh in h:
        if hh < pre:
            if hh >= pre - 1:
                pre = hh
            else:
                print('No')
                return
        pre = hh
        
    print('Yes')
    
if __name__ == '__main__':
    main()

# Fixed code:
def main():
    n = int(input())
    h = list(map(int, input().split()))
    
    pre = h[0]
    for hh in h:
        if hh < pre-1:
            print('No')
            return
        pre = max(pre, hh)
        
    print('Yes')
    
if __name__ == '__main__':
    main()
# Buggy code:
n = int(input())
h = list(map(int,input().split()))
b = ["True"]

if n == 1:
  print("Yes")
else:
  for i in range(n-1):
    d = h[i+1] - h[i]
    if d <= -2:
      print("No")
      break
    elif d >= 1:
      b.append("False")
      h[i+1] = h[i+1] - 1
      if i == n-2:
        print("Yes")
    elif d == 0:
      b.append("True")
      if i == n-2:
        print("Yes")
    elif d == -1:
      if b[i] == "True":
        h[i] = h[i] - 1
        b.append("True")
        if i == n-2:
          print("Yes")
      else:
        print("No")
        break

# Fixed code:
n = int(input())
h = list(map(int,input().split()))
b = ["True"]
 
if n == 1:
  print("Yes")
else:
  for i in range(n-1):
    d = h[i+1] - h[i]
    if d <= -2:
      print("No")
      break
    elif d >= 1:
      b.append("False")
      h[i+1] = h[i+1] - 1
      if i == n-2:
        print("Yes")
    elif d == 0:
      b.append("False")
      if i == n-2:
        print("Yes")
    elif d == -1:
      if b[i] == "True":
        h[i] = h[i] - 1
        b.append("True")
        if i == n-2:
          print("Yes")
      else:
        print("No")
        break
# Buggy code:
n=int(input())
hi=list(map(int, input().split()))

dhir={i:hi[n-1-i] for i in range(n)}
#print(dhir)

check=1
for i in range(n-1):
    if dhir[i] >= dhir[i+1]:
        continue
    elif dhir[i] == dhir[i+1]-1:
        dhir[i+1]-=1
        continue
    else:
        print(i)
        check=0

if check == 0:
    print("No")
else:
    print("Yes")


# Fixed code:
n=int(input())
hi=list(map(int, input().split()))

dhir={i:hi[n-1-i] for i in range(n)}

check=1
for i in range(n-1):
    if dhir[i] >= dhir[i+1]:
        continue
    elif dhir[i] == dhir[i+1]-1:
        dhir[i+1]-=1
        continue
    else:
        check=0

if check == 0:
    print("No")
else:
    print("Yes")
# Buggy code:
N = int(input())
H = list(map(int, input().split()))

for i in range(N-1):
    if H[i] >= H[i+1]:
        H[i] -= 1

if H == sorted(H):
    print('Yes')
else:
    print('No')

# Fixed code:
N = int(input())
H = list(map(int, input().split()))

for i in range(N):
    H[i] -= 1

for j in range(N-1):
    if H[j] > H[j+1]:
        H[j+1] += 1

if H == sorted(H):
    print('Yes')
else:
    print('No')
# Buggy code:
n = int(input())
h = list(map(int, input().split()))

for i in range(1, n):
    if h[i] < h[i-1]:
        h[i-1] = h[i-1] -1

for i in range(1, n):
    if h[i] < h[i-1]:
        print('No')
        break
    if i == n-1:
        print('Yes')

# Fixed code:
n = int(input())
h = list(map(int, input().split()))

if n == 1:
    print('Yes')
else:
    for i in range(n-1, 0, -1):
        if i == 1:
                print('Yes')
        else:
            if h[i] - h[i-1] == -1:
                h[i-1] -= 1
            elif h[i] - h[i-1] < -1:
                print('No')
                break
# Buggy code:
n = int(input())
h = list(map(int, input().split()))
for i in range(1, n):
    if h[i]<h[i-1]:
        h[i] -= 1
        if h[i]<h[i-1]:
            print('No')
            exit()
print('Yes')

# Fixed code:
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
for i in range(1,n):
    if (h[i] > h[i - 1]):
        h[i] -= 1
for i in range(1,n):
    if (h[i] < h[i - 1]):
        print("No")
        exit()
print("Yes")
# Buggy code:
N = int(input())
H = list(map(int, input().split()))[::-1]
high = H[0]
for i in range(1, N):
    if high - H[i] < -1:
        print("No")
        exit()
    else:
        high = H[i]
print("Yes")

# Fixed code:
N = int(input())
H = list(map(int, input().split()))[::-1]
high = H[0]
for i in range(1, N):
    if high - H[i] < -1:
        print("No")
        exit()
    else:
        high = min(H[i], high)
print("Yes")
# Buggy code:
N = int(input())
H = list(map(int,input().split()))

for i in range(1,N):
    ind = N - i - 1
    print(ind)
    if H[ind+1] == H[ind] - 1:
        H[ind] -= 1
    elif H[ind+1] < H[ind] - 1:
        print("No")
        exit()
print("Yes")


# Fixed code:
N = int(input())
H = list(map(int,input().split()))

for i in range(1,N):
    ind = N - i - 1
    if H[ind+1] == H[ind] - 1:
        H[ind] -= 1
    elif H[ind+1] < H[ind] - 1:
        print("No")
        exit()
print("Yes")
# Buggy code:
n=int(input())
s=[int(i) for i in input().split()]
s[0]-=1
b=True
for i in range(n-1):
    if(s[i+1]-s[i]==-1):
        if i!=0:
            if s[i]>s[i-1]:
                s[i]-=1
            else:
                b=False
                break
        else:
            s[i]-=1
    elif s[i+1]==s[i]:
        if s[i]>s[i-1]:
            s[i]-=1
    elif s[i+1]-s[i]<-1:
        b=False
        break
print(s)
if b:
    print("Yes")
else:
    print("No")


# Fixed code:
n=int(input())
s=[int(i) for i in input().split()]
s[0]-=1
b=True
for i in range(1,n):
    if s[i]>s[i-1]:
        s[i]-=1
    elif s[i]<s[i-1]:
        b=False
        break
if b:
    print("Yes")
else:
    print("No")
# Buggy code:
n = int(input())
l = [int(x) for x in input().split()]
#print(l)

for i in range(1,n)[::-1]:
    if l[i-1] - 1 == l[i]:
        l[i] = l[i] + 1
    else:
        continue
    
print(l)

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')


# Fixed code:
n = int(input())
l = [int(x) for x in input().split()]
#print(l)

for i in range(n-1)[::-1]:
    if l[i] - 1 == l[i+1]:
        l[i] = l[i] - 1
    else:
        continue
    
#print(l)

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')
# Buggy code:
N=int(input())
k=list(map(int,input().split()))
b = 0
for i in reversed(range(1, N)):
    if(k[i-1] > k[i]):
        k[i-1] -= 1
        if(k[i-1] > k[i]):
            print(i)
            b = 1

if(b == 0):
    print("Yes")
else:
    print("No")

# Fixed code:
N=int(input())
k=list(map(int,input().split()))
b = 0
for i in reversed(range(1, N)):
    if(k[i-1] > k[i]):
        k[i-1] -= 1
        if(k[i-1] > k[i]):
            b = 1


if(b == 0 or N == 1):
    print("Yes")
else:
    print("No")
# Buggy code:
N = int(input())
H = list(map(int,input().split()))

def main():
    for i in range(N-1,0,-1):
        if H[i-1] > H[i] + 1:
            print("No")
            return
    print("Yes")
    return

if __name__ == "__main__":
    main()

# Fixed code:
N = int(input())
H = list(map(int,input().split()))

def main():
    for i in range(N-1,0,-1):
        if H[i-1] > H[i] + 1:
            print("No")
            return
        elif H[i-1] == H[i] + 1:
            H[i-1] -= 1
    print("Yes")
    return

if __name__ == "__main__":
    main()
# Buggy code:
N = int(input())
H = list(map(int, input().split()))
ans = "Yes"
if len(H) == 1:
    print(ans)
else:
    for i in range(N-1):
        if H[i] - H[i+1] >= 2:
            ans = "No"
            break
    print(ans)

# Fixed code:
N = int(input())
H = list(map(int, input().split()))
ans = "Yes"
if len(H) == 1:
    print(ans)
else:
    for i in range(N-1):
        if H[-i-2] - H[-i-1] >= 2:
           ans = "No"
        elif H[-i-2] - H[-i-1] == 1:
            H[-i-2] = H[-i-2] - 1
    print(ans)
# Buggy code:
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
FL=False
Fx=-1
for i in range(n-1):
  if n==1:
    break
  if h[i]-h[i+1]==1:
    if FL:
      ans="No"
      break  
    else:
      FL=True
      Fx=h[i]
  if h[i]-h[i+1]>1:
    ans="No"
    break  
  else:
    if h[i]>=Fx:
      FL=False
print(ans)

# Fixed code:
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
FL=False
Fx=-1
for i in range(n-1):
  if n==1:
    break
  if h[i]>=Fx:
    FL=False 
  if h[i]-h[i+1]==1:
    if FL:
      ans="No"
      break  
    else:
      FL=True
      Fx=h[i]
  elif h[i]-h[i+1]>1:
    ans="No"
    break  
    
print(ans)
# Buggy code:
n = int(input())
numbers = list(map(int, input().split()))

def checkCondition():
  count = 0
  for i in range(n-1):
    if numbers[i] > numbers[i+1]:
      if numbers[i] - numbers[i+1] > 1:
        return False
      else:
        if count == 1:
          return False
        else:
          numbers[i+1] -= 1
          count += 1
  return True

if n == 1:
  print('Yes')
else:
  if checkCondition():
    print('Yes')
  else:
    print('No')

# Fixed code:
n = int(input())
numbers = list(map(int, input().split()))

def checkCondition():
  for i in range(n-1):
    if numbers[i] > numbers[i+1]:
      if numbers[i] - numbers[i+1] > 1:
        return False
  for i in range(-1, -n, -1):
    if numbers[i-1] - numbers[i] == 1:
      numbers[i-1] -= 1
    elif numbers[i-1] - numbers[i] > 1:
      return False
  return True

if n == 1:
  print('Yes')
else:
  if checkCondition():
    print('Yes')
  else:
    print('No')
# Buggy code:
N = int(input())
A = list(map(int, input().split()))
if N > 2:
    for i in range(N-2):
        if A[i]>A[i+1]:
            A[i] -= 1
    for i in range(N-2):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 2:
    if A[0] <= A[1]:
        print("Yes")
    else:
        print("No")
elif N == 1:
    print("Yes")


# Fixed code:
N = int(input())
A = list(map(int, input().split()))
if N > 1:
    A[0] -= 1
    for i in range(N-1):
        if A[i]<A[i+1]:
            A[i+1] -= 1
    for i in range(N-1):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 1:
    print("Yes")
# Buggy code:
n = int(input())
h = list(map(int, input().split()))
max_ = h[0]

for i in range(1, n - 1):
    max_ = max(max_, h[i])
    if max_ - h[i] >= 2:
        print("No")
        exit()
print("Yes")

# Fixed code:
import sys

n = int(input())
h = list(map(int, input().split()))
max_ = h[0]

for i in range(1, n - 1):
    max_ = max(max_, h[i])
    if max_ - h[i + 1] >= 2:
        print("No")
        sys.exit()
print("Yes")
# Buggy code:
n = int(input())
h = list(map(int, input().split()))

if n == 1:
	print('Yes')

ans = 0

for i in range(0,n-1):

	if h[i] == h[i + 1]:
		ans += 1
	elif h[i] > h[i + 1]:
		if h[i] - 1 == h[i + 1]:
			print('Yes')
			break
		else:
			print ('No')
			break
	elif h[i] < h[i + 1]:
		if h[i] == h[i + 1] - 1:
			print ('Yes')
			break
		else:
			print ('No')
			break

if ans == n-1:
	print('Yes')

# Fixed code:
n=int(input())
h=list(map(int,input().split()))
h[0]-=1
ans='Yes'
for i in range(1,n):
  if h[i]>h[i-1]:
    h[i]-=1
  if h[i]<h[i-1]:
    ans='No'
    break
print(ans)
# Buggy code:
N = int(input())
H = list(map( int, input().split()))
def solve():
  for i in range(N-1, 0, -1):
    if H[i-1]-H[i]>1>
    return False
  return True

print('Yes' if solve() else 'No')

# Fixed code:
N = int(input())
H = list(map( int, input().split()))
def solve():
  for i in range(N-1, 0, -1):
    if H[i-1]-H[i]>1:
      return False
    if H[i-1]-H[i]==1:
      H[i-1]-=1
  return True

print('Yes' if solve() else 'No')