func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 1000000404;   const long long MOD = 1000000007ll;   const long double PI = acos(-1.0);   const long double EPS = 1e-9;   template <typename t1, typename t2>   inline void upmax(t1 &a, t2 b) {     a = max(a, (t1)b);   }   template <typename t1, typename t2>   inline void upmin(t1 &a, t2 b) {     a = min(a, (t1)b);   }   template <typename T>   inline T gcd(T a, T b) {     return b ? gcd(b, a % b) : a;   }   template <typename T>   inline T lcm(T a, T b) {     return a * (b / gcd(a, b));   }   template <typename T>   inline T sqr(T a) {     return a * a;   }   template <typename T>   inline bool pal(T &x) {     int n = (int((x.size())));     for (int i = 0; i < n / 2; i++) {       if (x[i] != x[n - i - 1]) return 0;     }     return 1;   }   template <typename T>   inline void rev(T &x) {     int n = (int((x.size())));     for (int i = 0; i < n / 2; i++) swap(x[i], x[n - i - 1]);   }   int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};   int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};   inline long long mp(long long a, long long b) { return (a << 31) + b; }   class compare {    public:     bool operator()(const int a, const int b) const { return 1; }   };   int SQ = 400;   int l[211111];   int r[211111];   int m[211111];   int a[211111];   void solve() {     int n;     vector<int> st;     cin >> n;     for (int i = 1; i < n + 1; i++) {       cin >> a[i];     }     for (int i = 1; i < n + 1; i++) {       while (!st.empty() && a[st.back()] >= a[i]) st.pop_back();       if (st.empty())         l[i] = 0;       else         l[i] = st.back();       st.push_back(i);     }     st.resize(0);     for (int i = n + 1 - 1; i >= 1; i--) {       while (!st.empty() && a[st.back()] >= a[i]) st.pop_back();       if (st.empty())         r[i] = n + 1;       else         r[i] = st.back();       st.push_back(i);     }     st.resize(0);     for (int i = 1; i < n + 1; i++) upmax(m[r[i] - l[i] - 1], a[i]);     for (int i = n + 1 - 1; i >= 1; i--) upmax(m[i], m[i + 1]);     for (int i = 1; i < n + 1; i++) cout << m[i] <<    ;     cout << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       solve();     };     getchar();     getchar();     return 0;   }   