N = int(input()) A = list(map(int, input().split())) def judge(List): L = len(List) if L == 0: return True if L % 2 == 0: flag = True for i in range(L//2, L): if List[i] != 2*(i+1-L//2): flag = False break if flag: return judge(List[:L//2]) else: return False else: if List[-1] != L: if List[-1]!=0: return False else: return judge(List[:-2]) else: for i in range(L-1): List[i] += 1 List[0] = 0 return judge(List[:L-1]) R = -1 for i in range(N): if A[i] > 0: R = i A = A[:R+1] if judge(A): print("Yes") else: print("No")