#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; template struct FenwickTree { const int n; V t; FenwickTree(int n) : n(n), t(n + 1) {} void add(int i, T x) { for (++i; i <= n; i += i & -i) t[i] += x; } T sum(int i) const { T s = 0; for (; i; i -= i & -i) s += t[i]; return s; } T sum(int l, int r) const { return sum(r) - sum(l); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; V<> a(n); for (auto&& e : a) cin >> e, --e; if (a[0] > a.back()) { cout << "No" << '\n'; return 0; } cout << "Yes" << '\n'; V<> lc(n), rc(n); { FenwickTree ft(n); for (int i = 0; i < n; ++i) { lc[i] = ft.sum(a[i]); ft.add(a[i], 1); } } { FenwickTree ft(n); for (int i = n - 1; i >= 0; --i) { rc[i] = ft.sum(a[i], n); ft.add(a[i], 1); } } V<> b(n); for (int i = 0; i < n; ++i) { b[i] = lc[i] + rc[i]; } V<> idx(n); iota(begin(idx), end(idx), 0); sort(begin(idx), end(idx), [&](int i, int j) { return b[i] < b[j]; }); for (int i = 0; i < n - 1; ++i) { cout << a[idx[i]] + 1 << " \n"[i == n - 2]; } }