#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; std::vector newed; for (int i = 1; i + 1 < n; i++) { if (i + 2 < n && a[i] < a[i + 1]) std::cout << a[i] << " "; else newed.push_back(a[i]); } int i = 0; for (; i < (int) newed.size() && newed[i] > a[0]; i++) std::cout << newed[i] << " "; for (int j = (int) newed.size() - 1; j >= i; j--) std::cout << newed[i] << " "; std::cout << a[n - 1] << " "; std::cout << std::endl; } return 0; }