TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'

H[0] -= 1
for i in range(N-1):
    if H[i] < H[i+1]
        H[i+1] -= 1
    elif H[i] > H[i+1]
        ans = 'No'
        break

print(ans)


N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'

H[0] -= 1
for i in range(N-1):
    diff =  H[i+1] - H[i]
    if diff >= 0:
        H[i] -= 1
    elif diff < 0 :
        ans = 'No'
        break

print(ans)


import sys

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')
            sys.exit()
print('Yes')


import sys

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

if N == 1:
    print('Yes')
    sys.exit()
    
for i in range(1, N):
    if H[i] > H[i-1]:
        H[i] -= 1
        if H[i] > H[i-1]:
            print('No')
            sys.exit()
print('Yes')


N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'

H[0] -= 1
for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1
    elif H[i] > H[i+1]:
        ans = 'No'
        break

print(ans)


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N=int(input())
A=list(map(int, input().split()))
tmpmax=A[0]
ikeru=True
ok=True
for i in range(1,N):
  if tmpmax>A[i]:
    if tmpmax-1==A[i] and ok:
      tmpmax-=1
      ok=False
    else:
      ikeru=False
      break
  elif tmpmax==A[i] and ok==False:
    ikeru=False
    break
  else:
    ok=True
    tmpmax=A[i]

if ikeru:
  print("Yes")
else:
  print("No")

N=int(input())
A=list(map(int, input().split()))
tmpmax=A[0]
ikeru=True
ok=True
for i in range(1,N):
  if tmpmax>A[i]:
    if tmpmax-1==A[i] and ok:
      tmpmax-=1
      ok=False
    else:
      ikeru=False
      break
  elif tmpmax<A[i]:
    ok=True
    tmpmax=A[i]

if ikeru:
  print("Yes")
else:
  print("No")


Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
H = list(map(int, input().split()))
ans = 1
for i in range(N):
    if H[i] == H[i+1] or (H[i+1]-1):
        ans *= 1
    else:
        ans *= 0
print("Yes" if ans == 1 else "No")

N = int(input())
H = list(map(int, input().split()))
ans = 1
for i,j,k in zip(H,H[1::],H[2::]):
    if i == j:
        if j > k:
            ans *= 0
        else:
            break
    else i > j+1:
        ans *= 0
print("Yes" if ans == 1 else "No")


N = int(input())
H = list(map(int, input().split()))
ans = 1
for i,j,k in zip(H,H[1::],H[2::]):
    if i == j:
        if j > k:
            ans *= 0
    else i > j+1:
        ans *= 0
print("Yes" if ans == 1 else "No")


N = int(input())
H = list(map(int, input().split()))
for i,j in zip(H[N-1::-1],H[N-2::-1]):
    if j>i:
        if j>(i-1):
            print("No")
            exit()
print("Yes")


N = int(input())
H = list(map(int, input().split()))
ans = 1
for i,j,k in zip(H,H[1::],H[2::]):
    if i > (j+1):
        ans *= 0
    if i > j:
        if j >k:
            ans *=0
    if i == j:
        if j > k:
            ans *= 0
    print("Yes" if ans == 1 else "No")


N = int(input())
H = list(map(int, input().split()))
ans = 1
for i,j in zip(H,H[1::]):
    if i == j or i == j-1:
        ans *= 1
    else:
        ans *= 0
print("Yes" if ans == 1 else "No")

N = int(input())
H = list(map(int, input().split()))
for i in reversed(range(N-1)):
    print(i)
    if H[i]>H[i+1]:
        H[i] -= 1
        if H[i]>H[i+1]:
            print("No")
            exit()
print("Yes")


N = int(input())
H = list(map(int, input().split()))
for i in range(N,-1,-1):
    if H[i]>H[i-1]:
        H[i] -= 1
        if H[i]>H[i-1]:
            print("No")
            break()
print("Yes")



N = int(input())
H = list(map(int, input().split()))
for i in range(N,-1,-1):
    if H[i]>H[i-1]:
        H[i] -= 1
        if H[i]>H[i-1]:
            print("No")
            break
print("Yes")


N = int(input())
H = list(map(int, input().split()))
ans = 1
for i,j in zip(H[N-1::-1],H[N-2::-1]):
    if j>i:
        if j>(i-1):
            print("No")
            exit()
print("Yes")


N = int(input())
H = list(map(int, input().split()))
for i in reversed(range(N-1)):
    if H[i]>H[i+1]:
        H[i] -= 1
        if H[i]>H[i+1]:
            print("No")
            exit()
print("Yes")



Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):

N=int(input())
H=list(map(int, input().split()))
t=True
for i in range(1,N+1):
    M=max(H[:i])
    if M>min(H[i:])+1:
        print("No")
        t=False
        break
if t:
    print("Yes")


N=int(input())
H=list(map(int, input().split()))
t=True
for i in range(1,N+1):
    M=max(H[:i])
    if M>min(H[i:])+1:
        print("No")
        t=False
        break
if t:
    print("Yes")


N=int(input())
H=list(map(int, input().split()))
t=True
M=H[0]
for i in range(1,N):
    if M<H[i]:
        M=H[i]
    if M>H[i]+1:
        print("No")
        t=False
        break
if t:
    print("Yes")

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N=int(input())
H=list(map(int,input().split()))

for i in range(N-1):
	s=H[i:i+2]
	if s[0]-s[1] >0 and s[0]-s[1] ==1:
	    s[0] -=1
	H[i]=s[0]    
print(H)

max=H[0]
ans=False

for i in H:
    if i >= max:
        max=i
        ans=True
    else:
        ans=False
        
if ans:
    print('Yes')
else:
    print('No')
       

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

for i in range(1,N):
	
	if H[i-1]-H[i] ==1:
	    H[i] -=1
	
	if H[i-1]-H[i] <-1:
	    print('No')
	    exit()


print('Yes')

N=int(input())
H=list(map(int, input().split()))
h=H[::-1]
a=True

for i in range(N-1):
    if h[i] < h[i + 1]:
        if h[i+1]-h[i] <= 1:
            h[i+1] -=1
        else:
            a = False
            break

if a:
    print('Yes')
else:
    print('No')


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n=int(input())
H=list(map(int,input().split()))
ans='Yes'
for i in range(1,n-1):
    if H[i]<H[i-1] or H[i]-1>H[i+1]:
        ans='No'
        break
    
print(ans)

n=int(input())
H=list(map(int,input().split()))
ans='Yes'
ma=0
for i in range(1,n):
    if ma-1>H[i]:
        ans='No'
        break
    ma=max(ma,H[i])
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
hl = list(map(int,input().split()))

for i in range(1,n):
    if hl[i] - hl[i-1] > 1:
        print('No')
        exit()
print('Yes')


n = int(input())
hl = list(map(int,input().split()))

max_num = 0
for i in range(n):
    if hl[i] + 1 < max_num:
        print('No')
        exit()
    max_num = max(max_num, hl[i])
print('Yes')

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
h = list(map(int, input().split()))
if n==1:
    print('Yes')
    exit()
for i in range(n-1):
    if n[n-i] = n[n-i-1]-1:
        n[n-i-1] -= 1
    elif n[n-i] < n[n-i-1]-1:
        print('No')
        exit()
print('Yes')

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

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

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

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

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

n = int(input())
h = list(map(int, input().split()))
if n==1:
    print('Yes')
    exit()
ht = h[-1]
for i in reversed(range(n-1)):
    if ht == h[i]-1:
        h[i]-=1
    elif ht < h[i]-1:
        print('No')
        exit()
    ht = h[i]
print('Yes')

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
nums = [int(i) for i in input().split()]

bool = True
for i in range(0, len(nums), 1):
    t = nums[i] - 1
    if t > nums[i+1]:
        bool = False

if bool:
    print("Yes")
else:
    print("No")


n = int(input())
nums = [int(input()) for _ in range(n)]

bool = True
for i in range(n):
    t = nums[i] - 1
    if t > nums[i+1]:
        bool = False

if bool:
    print("Yes")
else:
    print("No")

n = int(input())
nums = [int(i) for i in input().split()]

bool = True
for i in range(len(nums)):
    if i == len(nums):
        break
    t = nums[i] - 1
    if t > nums[i+1]:
        bool = False

if bool:
    print("Yes")
else:
    print("No")


n = int(input())
nums = [int(i) for i in input().split()]

bool = True
for i in range(n):
    t = nums[i] - 1
    if t > nums[i+1]:
        bool = False

if bool:
    print("Yes")
else:
    print("No")

n = int(input())
nums = list(map(int, input().split()))

for i in range(1, n, 1):
    if nums[i] < nums[i - 1]:
        print("No")
        exit()

    if nums[i] > nums[i - 1]:
        nums[i] -= 1

print("Yes")


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n=int(input())
h = list(map(int,input().split()))



for i in range(n):

    if(i==0):
        pass
    elif( int(h[-(i+1)]) >= 1 + int(h[-i]) ):
        answer = "No"
        break
    elif(int(h[-(i+1)]) == 1 + int(h[-i])):
        tem = 1
    else:
        tem = 0

    answer = "Yes"


print(answer)


a = input().split()
N = int(a[0])
H = a[1:]
len(H)



for i in range(len(H)):

    if(i==0):
        pass
    elif( int(H[-(i+1)]) >= 1 + int(H[-i]) ):
        answer = "No"
        break
    elif(int(H[-(i+1)]) == 1 + int(H[-i])):
        tem = 1
    else:
        tem = 0

    answer = "Yes"


print(answer)

n=int(input())
h = list(map(int,input().split()))

tem =0

for i in range(n):

    if(i==0):
        pass
    elif( int(h[-(i+1)]) > 1 + int(h[-i]) - tem ):
        answer = "No"
        break
    elif(int(h[-(i+1)]) == 1 + int(h[-i]) - tem  ):
        tem = 1
    else:
        tem = 0

    answer = "Yes"


print(answer)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
hmax=h[0]
for i in range(1,n):
    if a[i]<hmax-1:
        ans="No"
        break
    else:
        hmax=max(hmax,a[i])
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans="Yes"
hmax=h[0]
for i in range(1,n):
    if h[i]<hmax-1:
        ans="No"
        break
    else:
        hmax=max(hmax,h[i])
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
H = list(map(int,input().split()))

for i in range(N-1):
    next = H[i+1]
    if H[i] - next > -1:
        print("No")
        exit()
    if H[i] - next == -1:
        H[i] -= 1

for i in range(N-1):
    if H[i] > H[i+1]:
        print("No")
        exit()
        
print("Yes")

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

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


Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n=int(input())
H=list(map(int,input().split()))
I=[0]*n
ans=True
for i in range(n-1):
    I[i+1]=max(I[i],H[i])
for j in range(n):
    if H[j]<I[j]+1:
        ans=False
        print("No")
        break
if ans:
    print("Yes")

n=int(input())
H=list(map(int,input().split()))
ans=True
for i in range(n-1):
    if H[i]>H[i+1]:
        H[i+1]+=1
for j in range(n-1):
    if H[j]>H[j+1]:
     print("No")
     ans=False
     break
if ans:
    print("Yes")

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
height_lists=list(map(int, input().split()))
for i in range(1,n):
    #print(i)
    #print(height_lists)
    #print()
    if height_lists[i-1] <= height_lists[i]:
        pass
    elif height_lists[i-1] < height_lists[i]:
        height_lists[i] -=1
cp_list = height_lists.copy()
cp_list.sort()
#print(height_lists)
#print(cp_list)

if cp_list == height_lists:
    print('Yes')
else:
    print('No')

n = int(input())
height_lists=list(map(int, input().split()))
for i in range(1,n):
    #print(i)
    #print(height_lists)
    #print()
    if height_lists[i-1] < height_lists[i]:
        height_lists[i] -=1
    else:
        pass
cp_list = height_lists.copy()
cp_list.sort()
#print(height_lists)
#print(cp_list)

if cp_list == height_lists:
    print('Yes')
else:
    print('No')

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N=int(input())
H=list(map(int,input().split()))
if len(H)==1:
  print("Yes")
  exit()
for i in range(1,N):
  if H[i-1]>H[i]-1:
    print("No")
    exit()
else:
  print("Yes")

N=int(input())
H=list(map(int,input().split()))
if len(H)==1:
  print("Yes")
  exit()
for i in range(1,N):
  if H[i-1]<H[i]-1:
    print("No")
    exit()
else:
  print("Yes")

N=int(input())
H=list(map(int,input().split()))
if len(H)==1:
  print("Yes")
  exit()
for i in range(1,N):
  if H[i-1]<=H[i]-1:
    H[i]-=1
  elif H[i-1]>H[i]:
    print("No")
    exit()
else:
  print("Yes")

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
A=list(map(int,input().split()))
i=N-2
j=0
ask=0
while(j<N):
    while(N-3-j<i):
        x=A[i+1]-A[i]
        if x<-1:
            ask=1
            break
        elif x==-1:
            A[i]=A[i]-1
            break
        i=i-1
    j=j+1
    i=N-2-j
if ask==0:
    print('Yes')
else:
    print('No')


N = int(input())
A=list(map(int,input().split()))
i=N-2
j=0
ask=0
while(j<N):
    while(N-3-j<i):
        x=A[i+1]-A[i]
        if x<-1:
            ask=1
            break
        elif x==-1:
            A[i]=A[i]-1
            break
        i=i-1
    j=j+1
    i=N-2
if ask==0:
    print('Yes')
else:
    print('No')

n=int(input())
a=list(map(int,input().split()))
for i in range(n-2,-1,-1):
    if a[i+1]<a[i]:
        a[i]-=1
for i in range(n-1):
    if a[i]>a[i+1]:
        print("No")
        exit()
print("Yes")

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
b=int(input())
a = [int(i) for i in input().split()]
a.insert(0,0)
for i in range(b):
  if a[i] < a[i+1]:
    a[i+1] -=1
print(a)
for i in range(b):
  if a[i] > a[i+1]:
    print('No')
    exit()
print('Yes')

b=int(input())
a = [int(i) for i in input().split()]
a.insert(0,0)
for i in range(b):
  if a[i] >= a[i+1]:
    a[i] -=1
print(a)
for i in range(b):
  if a[i] > a[i+1]:
    print('No')
    exit()
print('Yes')

b=int(input())
a = [int(i) for i in input().split()]
a.insert(0,0)

for i in range(b):
  if a[i] > a[i+1]:
    a[i] -= 1


for i in range(b):
  if a[i] >= a[i+1]:
    print('No')
    exit()
print('Yes')    

b=int(input())
a = [int(i) for i in input().split()]
a.insert(0,0)
for i in range(b):
  if a[i] >= a[i+1]:
    a[i] -=1
for i in range(b):
  if a[i] > a[i+1]:
    print('No')
    exit()
print('Yes')

b=int(input())
a = [int(i) for i in input().split()]
a.insert(0,0)
for i in range(1,b+1):
  if a[i-1] == a[i]:
    continue
  else:
    a[i] -= 1

for i in range(b):
  if a[i] > a[i+1]:
    print('No')
    exit()
print('Yes')

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
H = list(map(int, input().split()))

ans = 0

for i in reversed(range(0, N-1)):
    if H[i] > h[i+1] + 1:
        ans += 1
    elif H[i] == h[i+1] + 1:
        h[i] -= 1

if ans == 0:
    print('Yes')
else:
    print('No')

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

ans = 'Yes'

for i in reversed(range(0, N-1)):
    if H[i] > H[i+1] + 1:
        ans += 1
    elif H[i] == H[i+1] + 1:
        H[i] -= 1

if ans == 0:
    print('Yes')
else:
    print('No')

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

ans = 'Yes'

for i in reversed(range(0, N-1)):
    if H[i] > H[i+1] + 1:
        ans = 'No'
    elif H[i] == H[i+1] + 1:
        H[i] -= 1

print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
hoge_list = list(map(int,input().split()))
h_list = hoge_list[::-1]
mae = h_list[-1]
s = 0
for h in h_list:
  if h <= mae:
    mae = h
  elif h-1 = mae:
    mae = h-1
  else:
    print('No')
    s += 1
    break
if s == 0:
  print('Yes')

n = int(input())
hoge_list = list(map(int,input().split()))
h_list = hoge_list[::-1]
mae = h_list[0]
s = 0
for h in h_list:
  if h <= mae:
    mae = h
  elif h-1 == mae:
    mae = h-1
  else:
    print('No')
    s += 1
    break
if s == 0:
  print('Yes')

Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):





def main():
    n = int(input())
    h = list(map(int, input().split()))

    ans = 'Yes'
    
    for i in reversed(range(1,n)):
        if h[i-1] <= h[i]: continue
        if h[i-1] == h[i]-1:
          h[i] = h[i] -1
          continue
        ans = 'No'
        break
    print(ans)
    
if __name__ == '__main__':
    main()






def main():
    n = int(input())
    h = list(map(int, input().split()))

    ans = 'Yes'
    
    for i in reversed(range(1,n)):
        if h[i-1] <= h[i]: continue
        if h[i]-1 == h[i]: continue
        ans = 'No'
        break
    print(ans)
    
if __name__ == '__main__':
    main()






def main():
    n = int(input())
    h = list(map(int, input().split()))

    ans = 'Yes'
    
    for i in reversed(range(1,n)):
        if h[i-1] <= h[i]: continue
        if h[i-1]-1 == h[i]:
          h[i-1] = h[i-1] - 1
          continue
        ans = 'No'
        break
    print(ans)
    
if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
h = list(map(int, input().split()))
tmp = h[-1]
ans = 'Yes'

for i in range(2,n+1):
    print(tmp, h[-i],i)
    if tmp - h[-i] == -1:
        tmp = h[-i]-1
    elif tmp - h[-i] < -1:
        ans = 'No'
        break
    else:
        tmp = h[-i]

print(ans)

n = int(input())
h = list(map(int, input().split()))
tmp = h[-1]
ans = 'Yes'

for i in range(2,n+1):
    if tmp - h[-i] == -1:
        tmp = h[-i]-1
    elif tmp - h[-i] < -1:
        ans = 'No'
        break
    else:
        tmp = h[-i]

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
h = list(map(int, input().split()))

for i in range(n-1):
    if h[i] >= h[i+1]:
        h[i] -= 1
for i in range(n-1):
    if h[i] < h[i+1]:
        print("No")
        exit()
print("Yes")

n = int(input())
h = list(map(int, input().split()))
for i in range(1, n):
    if h[i-1] < h[i]:
        h[i] -= 1
for i in range(1, n):
    if h[i-1] > h[i]:
        print("No")
        exit()
print("Yes")

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
import sys
N=int(input())

H=[int(x) for x in input().rstrip().split()]
flag=0
mi=-1
for i in range(N-1):
  mi=max(H[i],mi)
  if H[i]<=H[i+1] and mi<=H[i]:

    continue
  elif H[i+1]<H[i]:
    H[i]=H[i]-1

    if H[i+1]<H[i] or H[i]<mi:
      flag=1
      print("No")
      sys.exit()

if flag==0:
  print("Yes")









import sys
N=int(input())

H=[int(x) for x in input().rstrip().split()]
flag=0
mi=-1
for i in range(N-1):

  if H[i]<=H[i+1] and mi<=H[i]:
    mi=max(mi,H[i]-1)
    continue
  elif H[i+1]<H[i]:
    H[i]=H[i]-1
    mi=max(mi,H[i])
  if H[i+1]<H[i] or H[i]<mi:
    flag=1
    print("No")
    sys.exit()

if flag==0:
  print("Yes")



Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
#!/usr/bin/env python3

n = int(input())
h = list(map(int, input().split()))

h.reverse()


ans = 0
for i in range(1, len(h)):
    if h[i-1]-h[i] >= 0:
        continue
    elif h[i-1]-h[i] == 0:
        h[i] -= 1
    else:
        print("No")
        exit()

print("Yes")


#!/usr/bin/env python3

n = int(input())
h = list(map(int, input().split()))

h.reverse()


ans = 0
for i in range(1, len(h)):
    if h[i-1]-h[i] >= 0:
        continue
    elif h[i-1]-h[i] == -1:
        h[i] -= 1
    else:
        print("No")
        exit()

print("Yes")


Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
def main():
    n = int(input())
    h = list(map(int, input().split()))

    pre = 0
    flag = True
    for i in range(n):
        if h[i] >= pre + 1:
            h[i] -= -1
        if h[i] < pre:
            flag = False
            break
        pre = h[i]
    
    if flag:
        print('Yes')
    else:
        print('No')
                

if __name__ == '__main__':
    main()

def main():
    n = int(input())
    h = list(map(int, input().split()))

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

if __name__ == '__main__':
    main()

def main():
    n = int(input())
    h = list(map(int, input().split()))

    pre = 0
    for i in range(n):
        if h[i] >= pre + 1:
            h[i] -= -1
        if h[i] == pre:
            pass
        if h[i] < pre:
            print('No')
            break
        pre = h[i]
    
    print('Yes')
                

if __name__ == '__main__':
    main()

def main():
    n = int(input())
    h = list(map(int, input().split()))

    pre = 0
    for i in range(n):
        if h[i] >= pre + 1:
            h[i] -= -1
        if h[i] < pre:
            print('No')
            exit
        pre = h[i]
    
    print('Yes')
                

if __name__ == '__main__':
    main()

def main():
    n = int(input())
    h = list(map(int, input().split()))
    flag = True
    for i in range(n-1):
        if h[i+1] - h[i] == 0:
            continue
        elif h[i+1] - h[i] >= 1:
            h[i+1] = h[i+1] - 1
        else:
            flag = False 
    if flag:
        print('Yes')
    else:
        print('No')
            
if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n=int(input())
h_list=[int(s) for s in input().split()]

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

left=h_list[0]
for i in range(1,n):
    right=h_list[i]

    if left+1<right:
        left=right-1
    if left==right:
        continue
    print('No')
    exit()


print('Yes')

n=int(input())
h_list=[int(s) for s in input().split()]

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

left=h_list[0]
for i in range(1,n):
    right=h_list[i]

    if left<right:
        left=right-1
    if left==right:
        continue
    print('No')
    exit()


print('Yes')

n=int(input())
h_list=[int(s) for s in input().split()]

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

left=h_list[0]
for i in range(1,n):
    right=h_list[i]

    if left<right:
        left=right-1
        continue
    if left==right:
        continue
    print('No')
    exit()


print('Yes')

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
i = n-1
while (i > 1):
    if (a[i-1] > a[i]):
        a[i-1] -= 1
    i -= 1

j = 0
c = 0

while (j < n-1):
    if (a[j] > a[j+1]):
        c += 1
    j += 1
if (c == 0):
    print('Yes')
else:
    print('No')
print (a,c)

n = int(input())
a = list(map(int, input().split()))
i = n-1
while (i > 1):
    if (a[i-1] > a[i]):
        a[i-1] -= 1
    i -= 1

j = 0
c = 0

while (j < n-1):
    if (a[j] > a[j+1]):
        c += 1
    j += 1
if (c == 0):
    print('Yes')
else:
    print('No')
print (a)

n = int(input())
a = list(map(int, input().split()))
i = n-1
while (i > 1):
    if (a[i-1] > a[i]):
        a[i-1] -= 1
    i -= 1

j = 0
c = 0

while (j < n-1):
    if (a[j] > a[j+1]):
        c += 1
    j += 1
if (c == 0):
    print('Yes')
else:
    print('No')

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
H = list(map(int, input().split()))
ans = True
if N != 1:
    for i in range(N - 1):
        if i == N - 2:
            if (H[i] - 1) <= H[i + 1]:
                continue
            else:
                ans = False
        elif (H[i] - 1) <= H[i + 1] and (H[i]) <= H[i + 2]:
            continue
        else:
            ans = False
            break
if ans:
    print("Yes")
else:
    print("No")

N = int(input())
H = list(map(int, input().split()))
H.append(H[N - 1])
ans = True
ma = H[0]
if N != 1:
    for i in range(N - 1):
        ma = max(ma, H[i + 1])
        if ma - 1 > H[i + 1]:
            ans = False
            break
        elif H[i] <= H[i + 1]:
            continue
        elif H[i] - 1 <= H[i + 1]:
            H[i] = H[i] - 1
        else:
            ans = False
            break
if ans:
    print("Yes")
else:
    print("No")

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
li = list(map(int, input().split()))
ans = "Yes"
count = N - 1
while count >= 0:
    if li[count] - li[count-1] >= 0:
        pass
    elif li[count] - li[count-1] == -1:
        li[count-1] -= 1
    else:
        ans = "No"
        break
    count -= 1
print(ans)

N = int(input())
li = list(map(int, input().split()))
ans = "Yes"
count = N - 1
while count >= 0:
    if li[count] - li[count-1] => 0:
        pass
    elif li[count] - li[count-1] == -1:
        li[count-1] -= 1
    else:
        ans = "No"
        break
    count -= 1
print(ans)

N = int(input())
li = list(map(int, input().split()))
ans = "Yes"
count = N - 1
while count >= 0:
    if li[count] - li[count-1] => 0:
        pass
    elif li[count] - li[count-1] = -1:
        li[count-1] -= 1
    else:
        ans = "No"
        break
    count -= 1
print(ans)

N = int(input())
li = list(map(int, input().split()))
ans = "Yes"
count = N - 1
while count >= 0:
    if li[count] - li[count-1] < -1:
        ans = "No"
        break
    elif li[count] - li[count-1] == -1:
        if count == 1:
            ans = "No"
            break
        else:
            tmp = count -2
            while tmp >= 0:
                if li[count] - li[tmp] <= -2:
                    ans = "No"
                    break
                elif li[count] >= li[tmp]:
                    count = tmp
                    break
                tmp -= 1
            if ans == "No":
                break
            count -= 1
print(ans)

N = int(input())
li = list(map(int, input().split()))
ans = "Yes"
count = N - 1
while count >= 1:
    if li[count] - li[count-1] >= 0:
        pass
    elif li[count] - li[count-1] == -1:
        li[count-1] -= 1
    else:
        ans = "No"
        break
    count -= 1
print(ans)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Time Limit Exceeded

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
L = list(map(int,input().split()))[::-1]

flag = True
for i in range(n-1):
    if L[i]-1 <= L[i+1]:
        continue
    else:
        flag = False
if flag:
    print("Yes")
else:
    print("No")

    n=int(input())
    li=list(map(int,input().split()))
    max1 = li[0]
    ans = ""
    if n == 1:
        print("Yes")
    for i in range(n-1):
        if li[i]<=li[i+1]:
            max1 = li[i+1]
            ans = "Yes"
            
        elif li[i]>li[i+1]:
            max1 = li[i]
            if max1-1>li[i+1]:
                ans ="No"
                break
            else:
                continue
        else:
            break
     
    print(ans)

n = int(input())
li = list(map(int,input().split()))
li = li[::-1]
#print(li)
ans = ""
for i in range(n-1):
    if li[i]<li[i+1]:
        if li[i]<=li[i+1]-1:
            ans ="No"
            break
    else:
        ans = "Yes"

print(ans)

n = int(input())
L = list(map(int,input().split()))
if n == 1:
    print("Yes")
    exit()
    
flag = False
for i in range(n-1):
    if L[i+1] >= L[i]:
        flag = True
    else:
        if L[i+1] == L[i]-1:
            L[i+1] +=1
            flag = True
        elif L[i+1] < L[i]-1:
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
h = list(map(int, input().split()))
             
if n == 1:
      print("Yes")
else:
      for i in range(n-1):
            if h[i+1] <= h[i]:
                  h[i] -= 1
      for i in range(n-1):
            if h[i+1] < h[i]:
                  print("No")
                  break 
      else:
    	    print("Yes")

n = int(input())
h = list(map(int, input().split()))
             
if n == 1:
      print("Yes")
else:
      for i in range(n-1):
            if h[i+1] < h[i]:
                  h[i+1] -= 1
      for i in range(n-1):
            if h[i+1] < h[i]:
                  print("No")
                  break
      else:
    	    print("Yes")


n = int(input())
h = list(map(int, input().split()))

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

n = int(input())
h = list(map(int, input().split()))
         
if n == 1:
	print("Yes")
else:
	for i in range(n-1):
		if h[i+1] < h[i]:
		h[i+1] -= 1
	for i in range(n-1):
		if h[i+1] < h[i]:
  			print("No")
  			break
	else:
		print("Yes")

n = int(input())
h = list(map(int, input().split()))
     
if n == 1:
	print("Yes")
else:
    for i in range(n-1):
    	if h[i+1] < h[i]:
        h[i+1] -= 1
    for i in range(n-1):
        if h[i+1] < h[i]:
          print("No")
          break
    else:
        print("Yes")

n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
             
if n == 1:
      print("Yes")
else:
      for i in range(n-1):
            if h[i] < h[i+1]:
                  h[i+1] -= 1
      for i in range(n-1):
            if h[i+1] < h[i]:
                  print("No")
                  break
      else:
            print("Yes")
                  

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):

def hoge(lst,i):
    if lst[i]==lst[i+1]:
        hoge(lst,i+1)
    if lst[i]>lst[i+1]:return True
    if lst[i]<lst[i+1]:return False

N = int(input())
H = list(map(int,input().split()))
det=0

for i in range(N-1):
    if H[i]-1>H[i+1]:
        det+=1
        print("No")
        break
    if i+2<=N-1:
        if H[i]>H[i+1] and H[i+1] > H[i+2]:
            det+=1
            print("No")
            break
        if hoge(H,i):
            det+=1
            print("No")
            break
if det==0:print("Yes")


def hoge(lst,i):
    if lst[i]==lst[i+1] and len(lst)>i+2:
        return hoge(lst,i+1)
    if lst[i]>lst[i+1]:return True
    if lst[i]<lst[i+1]:return False

N = int(input())
H = list(map(int,input().split()))
det=0

for i in range(N-1):
    if H[i]-1>H[i+1]:
        det+=1
        print("No")
        break
    if i+2<=N-1:
        if H[i]>H[i+1] and H[i+1] > H[i+2]:
            det+=1
            print("No")
            break
        if H[i]>H[i+1] and hoge(H,i+1):
            det+=1
            print("No")
            break
if det==0:print("Yes")

Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
h_list = map(int, input().split())
h = 0
result = 'Yes'
for i in range(n):
  if h <= h_list[i]:
    h = h_list[i]
  elif h == h_list[i]-1:
    h = h_list[i]-1
  else:
    result = 'No'
print(result)

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


Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
H = list(map(int,input().split()))
if N == 1:
    print('Yes')
    exit()
for i in range(N-1):
    if H[i] == H[i+1]:
        pass
    elif H[i] < H[i+1]:
        H[i+1] -= 1
    else:
        print('No')
        exit()
input('Yes')


N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print('Yes')
    exit()
for i in range(N-1):
    if H[i] == H[i+1]:
        continue
    elif H[i] < H[i+1]:
        H[i+1] -= 1
    else:
        print('No')
        exit()
print('Yes')


Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n=int(input())
h=list(map(int,input().split()))
for i in range(n-1):
  if h[n-2-i]-1>h[n-1-i]:
      print('No')
      exit()
  elif h[n-2-i]-1=h[n-1-i]:
      h[n-2-i]=h[n-2-i]-1
print('Yes')

n=int(input())
h=list(map(int,input().split()))
for i in range(n-1):
  if h[n-2-i]-1>h[n-1-i]:
      print('No')
      exit()
  elif h[n-2-i]-1==h[n-1-i]:
      h[n-2-i]=h[n-2-i]-1
print('Yes')

Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
H = list(map(int, input().split()))

H.append(H[-1])

for n in range(N):
    if (H[n+1] - H[n]) > 1:
        H[n+1] -= 1
    if (H[n+1] - H[n]) < 0:
        print("No")
        exit(0)
    
print("Yes")

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

H.append(H[-1])
H.append(H[-1])

for n in range(N):
    if (H[n+1] - H[n]) > 1:
        H[n+1] -= 1
    if (H[n+1] - H[n]) < 0:
        print("No")
        exit(0)
        
for n in range(N):
    if (H[n+1] - H[n]) > 1:
        H[n+1] -= 1
    if (H[n+1] - H[n]) < 0:
        print("No")
        exit(0)
    
print("Yes")

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

H.append(H[-1])
H.append(H[-1])

for n in range(N):
    if (H[n+1] - H[n]) > 1:
        H[n+1] -= 1
    if (H[n+1] - H[n]) < 0:
        print("No")
        exit(0)
    
print("Yes")

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

H.append(H[-1])
H.append(H[-1])

for n in range(N):
    if (H[n+1] - H[n]) > 1:
        H[n+1] -= 1
        
for n in range(N):
    if (H[n+1] - H[n]) < 0:
        print("No")
        exit()
    
print("Yes")

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

H.append(H[-1])
H.append(H[-1])

#print(H)

for n in range(N):
    if H[n+1] > H[n]:
        H[n+1] -= 1
    #print(H)
    
for n in range(N):
    if H[n+1] < H[n]:
        print("No")
        exit()

print("Yes")

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted