#include #define rep(i, a, b) for(int i = (a); i <= (b); i ++) using std::cin, std::cout, std::cerr; using ll = long long; void Solve() { int n; cin >> n; std::vector a(n); rep(i, 0, n - 1) cin >> a[i]; if(a[0] > a[n - 1]) { cout << "No\n"; return; } cout << "Yes\n"; std::vector stack = {a[0]}; rep(i, 1, n - 1) { while(stack.size() > 1 && stack.back() < a[i]) { cout << stack.back() << ' '; stack.pop_back(); } if(a[i] < stack.back()) { stack.push_back(a[i]); } else { cout << a[i] << ' '; } } cout << '\n'; } int main() { std::ios::sync_with_stdio(false); int T = 1; while(T --) { Solve(); } }