local n = io.read("*n") local a = {} local ainv = {} for i = 1, n do ainv[i] = 0 end for i = 1, n do a[i] = io.read("*n") ainv[a[i]] = i end local t = {} for i = n, 1, -1 do if ainv[i] == n then for j = n - 1, 1, -1 do if a[j] < i then table.insert(t, a[j]) end end print("Yes") print(table.concat(t, " ")) break elseif 1 < ainv[i] then table.insert(t, i) else print("No") break end end