n = int(input()) A = list(map(int, input().split())) if A[0] > A[-1]: print("No") exit() print("Yes") stack = [A[0]] ans = [] for a in A[1:n-1]: if stack[-1] < a: ans.append(a) else: stack.append(a) ans += stack[::-1] print(*ans)