N = int(input()) A = [0] + list(map(int,input().split())) maxN = N + 1 flag = 1 while flag == 1: flag = 0 maxNt = maxN for i in reversed(range(1,maxN)): if flag == 0: if i == 1 and A[i] == 0: flag = 2 break elif A[i] == 0: dummy = 0 elif A[i] != i: break else: flag = 1 maxNt = i + 1 if flag == 1: if A[i] == i: if i == 1: A[i] = 0 elif A[i-1] != i - 1: A[i-1] += 1 A[i] = 0 maxN = maxNt if flag == 2: break if flag == 0: print("No") else: print("Yes")