import sys sys.setrecursionlimit(10**6) N = int(input()) a = list(map(int,input().split())) if a[0] > a[-1]: print("No") exit() print('Yes') l = [0]+[i for i in range(N-1)] r = [i for i in range(1,N)]+[N-1] ans = [] def func(x): if x == 0 or x == N-1: return if a[l[x]] < a[x]: ans.append(a[x]) r[l[x]] = r[x] l[r[x]] = l[x] if a[x] < a[r[x]]: ans.append(a[x]) r[l[x]] = r[x] l[r[x]] = l[x] func(l[x]) func(r[x]) func(1) for i in ans: print(i,end=" ") print(a[0])