class Binary_Indexed_Tree: def __init__(self, n) -> None: self._n = n self.data = [0] * (n+1) self.depth = n.bit_length() def add(self, p, x) -> None: """任意の要素ai←ai+xを行う O(logn)""" assert 0 <= p < self._n p += 1 while p <= self._n: self.data[p-1] += x p += p & (-p) def sum(self, l, r) -> int: """区間[l,r)で計算""" assert 0 <= l <= r <= self._n return self._sum(r) - self._sum(l) def _sum(self, d) -> int: sm = 0 while d > 0: sm += self.data[d-1] d -= d & (-d) return sm N = int(input()) A = list(map(int, input().split())) if A[-1]==1: print('No') exit() BIT = Binary_Indexed_Tree(N+5) posi = [-1]*(N+1) for i in range(N): BIT.add(i,1) posi[A[i]] = i n = N num = A[-1] ans = [] while n>num: p = posi[n] sm = BIT._sum(p) if sm>0: BIT.add(p,-1) ans.append(n) n -= 1 else: print('No') exit() for i in range(N-2,-1,-1): if BIT.sum(i,i+1)>0: ans.append(A[i]) print('Yes') print(*ans)