func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void next_int(T &x) {     x = 0;     char c;     bool neg = false;     while (!isdigit(c = getchar()))       if (c ==  - ) neg = true;     do x = x * 10 + c - 48;     while (isdigit(c = getchar()));     if (neg) x = -x;   }   template <typename T>   inline void write_int(T x, char last = 0) {     if (x < 0) putchar( - ), x = abs(x);     char tmp[20];     int cnt = 0;     while (x >= 10) tmp[cnt++] = x % 10 + 48, x /= 10;     tmp[cnt] = x + 48;     for (int i = (cnt); i >= (0); --i) putchar(tmp[i]);     if (last) putchar(last);   }   struct Line {     long long a, b;     Line(long long _a, long long _b) : a(_a), b(_b) {}   };   const int N = (int)2e5 + 5;   vector<Line> hull;   int n;   long long a[N], sum[N], sum2[N];   bool bad(Line l1, Line l2, Line l3) {     return (l1.b - l3.b) * (l2.a - l1.a) <= (l3.a - l1.a) * (l1.b - l2.b);   }   void add(Line x) {     while (((int)hull.size()) >= 2 &&            bad(hull[((int)hull.size()) - 2], hull[((int)hull.size()) - 1], x))       hull.pop_back();     hull.push_back(x);   }   long long getval(int pos, long long x) {     if (pos >= ((int)hull.size())) return (long long)1e18 + 7;     return hull[pos].a * x + hull[pos].b;   }   long long read(long long x) {     int lo = 0, hi = ((int)hull.size()) - 1, mid;     while (lo != hi) {       mid = (lo + hi) >> 1;       if (getval(mid, x) <= getval(mid + 1, x))         hi = mid;       else         lo = mid + 1;     }     return getval(lo, x);   }   int main() {     next_int(n);     for (int i = (1); i <= (n); ++i) {       next_int(a[i]);       sum[i] = sum[i - 1] + a[i];       sum2[i] = sum2[i - 1] + (long long)i * a[i];     }     add(Line(0, 0));     long long res = 0;     for (int i = (1); i <= (n); ++i) {       res = max(res, -read(-sum[i]) + sum2[i]);       add(Line(-i, sum2[i] - (long long)i * sum[i]));     }     write_int(res);     return 0;   }   