#include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); int a[n]; for (int i = 0; i < n; i++) a[i] = ri(); if (a[0] > a[n - 1]) std::cout << "No" << std::endl; else { std::cout << "Yes" << std::endl; if (n == 2) { std::cout << a[1] << std::endl; return 0; } std::vector newed{a[1]}; for (int i = 2; i + 1 < n; i++) { while (newed.size() && newed.back() < a[i]) std::cout << newed.back() << " ", newed.pop_back(); newed.push_back(a[i]); } for (auto i : newed) std::cout << i << " "; std::cout << a[n - 1] << std::endl; } return 0; }