#include #include #include void solve() { int n; std::cin >> n; std::set rem; for (int i = 1; i <= n; ++i) rem.insert(i); std::vector ans; std::vector stk; while (n--) { int x; std::cin >> x; rem.erase(x); if (stk.empty() || x < stk.back()) { stk.push_back(x); } else if (rem.lower_bound(stk.front()) == rem.end()) { if (x < stk.front()) { std::cout << "No\n"; return; } while (!stk.empty()) { ans.push_back(stk.back()); stk.pop_back(); } stk.push_back(x); } else { ans.push_back(x); } } if (stk.size() != 1) { std::cout << "No\n"; } else { std::cout << "Yes\n"; for (auto a : ans) std::cout << a << " "; std::cout << "\n"; } } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }