func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   bool isV(char x) {     if (x ==  a  || x ==  e  || x ==  i  || x ==  o  || x ==  u ) {       return 1;     }     return 0;   }   bool isP(long long n) {     for (long long i = 2; i * i <= n; i++) {       if (n % i == 0) return 0;     }     return 1;   }   void fio() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   void print(long long* a, long long n) {     long long i;     for (i = 0; i < (long long)n; i++) {       cout << a[i] <<    ;     }     cout << endl;   }   void print2d(long long a[][1000], long long m, long long n) {     long long i, j;     for (i = 0; i < (long long)m; i++) {       for (j = 0; j < (long long)n; j++) {         cout << setw(2) << a[i][j];       }       cout << endl;     }   }   int32_t main() {     fio();     long long n;     cin >> n;     long long* a = new long long[n];     long long i;     for (i = 0; i < (long long)n; i++) {       cin >> a[i];     }     long long* suf = new long long[n];     suf[n - 1] = 0;     stack<long long> s;     for (i = n - 1; i >= (long long)0; i--) {       while (s.size() > 0 && a[i] <= a[s.top()]) s.pop();       if (s.size() != 0) {         suf[i] = suf[s.top()] + (s.top() - i - 1) * a[i] + a[s.top()];       } else {         suf[i] = (n - (i + 1)) * a[i];       }       s.push(i);     }     long long* temp = new long long[n];     long long* pref = new long long[n];     pref[0] = 0;     long long m = 0, mi = -1;     stack<long long> x;     for (i = 0; i < (long long)n; i++) {       while (x.size() > 0 && a[x.top()] > a[i]) x.pop();       if (x.size() == 0)         pref[i] = i * a[i];       else         pref[i] = pref[x.top()] + (i - x.top() - 1) * a[i] + a[x.top()];       x.push(i);       if (m < pref[i] + suf[i] + a[i]) {         m = pref[i] + suf[i] + a[i];         mi = i;       }     }     for (i = mi + 1; i < (long long)n; i++) {       if (a[i] > a[i - 1]) a[i] = a[i - 1];     }     for (i = mi - 1; i >= (long long)0; i--) {       if (a[i] > a[i + 1]) a[i] = a[i + 1];     }     for (i = 0; i < (long long)n; i++) cout << a[i] <<    ;   }   