//#define _GLIBCXX_DEBUG #include "bits/stdc++.h" using namespace std; //------------------------------- Libraries --------------------------------// //------------------------------- Type Names -------------------------------// using i64 = int_fast64_t; using seika = string; //{akari : 1D, yukari : 2D, maki : 3D} vector template using akari = vector; template using yukari = akari>; template using maki = akari>; //{akane : ascending order, aoi : decending order} priority queue template using akane = priority_queue, greater>; template using aoi = priority_queue; //------------------------------- Dubug Functions ---------------------------// inline void print() { cout << endl; } template void print(const First &first, const Rest &... rest) { cout << first << ' '; print(rest...); } //------------------------------- Solver ------------------------------------// void solve() { int n; cin >> n; akari as(n), ans; for (int i = 0; i < n; i++) { cin >> as[i]; } if (as.front() > as.back()) { cout << "No" << endl; return; } int l = 1, r = n - 2; while (l <= r) { if (as[0] < as[l] || as[l] < as[l + 1]) { ans.push_back(as[l]); l++; } else if (as[r] < as[n - 1] || as[r - 1] < as[r]) { ans.push_back(as[r]); r--; } else { cout << "No" << endl; return; } } cout << "Yes" << endl; ans.push_back(as[0]); for (int a : ans) { cout << a << ' '; } cout << endl; } int main() { solve(); return 0; }