n = int(input()) A = list(map(int,input().split())) start = A[0] l = [] rest = [] for a in A[1:]: while rest and rest[-1] < a: l.append(rest.pop()) if start < a: l.append(a) else: rest.append(a) if rest: print("No") else: print("Yes") print(*l)