#include #include using namespace std; int main(){ int n;cin>>n; vector A(n); for(int i = 0; n > i; i++){ cin>>A[i]; } if(A[0] > A[n-1]){ cout << "No" << endl; return 0; } int nw = A[0]; vector ret; vector ret2; for(int i = 1; n-1 > i; i++){ if(nw < A[i]){ ret.push_back(A[i]); }else{ ret2.push_back(nw); nw = A[i]; } } vector o; for(int i = 0; ret.size() > i; i++)o.push_back(ret[i]); o.push_back(nw); for(int i = ret2.size()-1; 0 <= i; i--)o.push_back(ret2[i]); for(int i = 0; o.size() > i; i++){ cout << o[i] << " \n"[i==o.size()-1]; } }