func_code_string: #include <bits/stdc++.h>   using namespace std;   long long MOD = 1000000007;   long long INF = 1LL << 60;   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n;     cin >> n;     vector<long long> l(n), r(n), m(n);     for (long long i = (long long)(0); i < (n); i++) {       cin >> m[i];     }     stack<pair<long long, long long>> stk;     stk.push(make_pair(0, -1));     stk.push(make_pair(m[0], 0));     l[0] = m[0];     for (long long i = (long long)(1); i < (n); i++) {       if (m[i] > stk.top().first) {         l[i] = l[i - 1] + m[i];       } else {         while (!stk.empty() && m[i] < stk.top().first) {           stk.pop();         }         int ind = stk.top().second;         long long prv;         if (ind == -1) {           prv = 0;         } else {           prv = l[ind];         }         l[i] = prv + (i - ind) * m[i];       }       stk.push(make_pair(m[i], i));     }     while (!stk.empty()) {       stk.pop();     };     reverse(m.begin(), m.end());     ;     stk.push(make_pair(0, -1));     stk.push(make_pair(m[0], 0));     r[0] = m[0];     for (long long i = (long long)(1); i < (n); i++) {       if (m[i] > stk.top().first) {         r[i] = r[i - 1] + m[i];       } else {         while (!stk.empty() && m[i] < stk.top().first) {           stk.pop();         }         int ind = stk.top().second;         long long prv;         if (ind == -1) {           prv = 0;         } else {           prv = r[ind];         }         r[i] = prv + (i - ind) * m[i];       }       stk.push(make_pair(m[i], i));     };     reverse(m.begin(), m.end());     ;     ;     reverse(r.begin(), r.end());     ;     int ind = 0;     long long out = 0;     long long temp;     for (long long i = (long long)(0); i < (n); i++) {       temp = l[i] + r[i] - m[i];       if (temp > out) {         ind = i;         out = temp;       }     }     vector<long long> outt(n);     outt[ind] = m[ind];     long long big = m[ind];     for (int i = ind - 1; i >= 0; i--) {       if (m[i] < big) {         big = m[i];       }       outt[i] = big;     }     big = m[ind];     for (int i = ind + 1; i < n; i++) {       if (m[i] < big) {         big = m[i];       }       outt[i] = big;     }     for (long long i = (long long)(0); i < (n); i++) {       cout << outt[i] <<    ;     }   }   