func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int read() {     char x =   0 ;     int fh = 1, sum = 0;     for (x = getchar(); x <  0  || x >  9 ; x = getchar())       if (x ==  - ) fh = -1;     for (; x >=  0  && x <=  9 ; x = getchar()) sum = sum * 10 + x -  0 ;     return fh * sum;   }   const int N = 1e5 + 9;   int fa[N], ch[N][2], sz[N];   long long A[N], B[N], val[N];   int n, a, rt, cnt;   inline long long pd(int x) { return ch[fa[x]][1] == x; }   inline void pushup(int x) {     int ls = ch[x][0], rs = ch[x][1];     sz[x] = sz[ls] + sz[rs] + 1;   }   inline void modify(int x, long long a, long long b) {     val[x] += a * (sz[ch[x][0]] + 1) + b;     A[x] += a, B[x] += b;   }   inline void pushdown(int x) {     if (A[x] || B[x]) {       if (ch[x][0]) modify(ch[x][0], A[x], B[x]);       if (ch[x][1]) modify(ch[x][1], A[x], B[x] + A[x] * (sz[ch[x][0]] + 1));       A[x] = B[x] = 0;     }   }   inline void rotate(int x) {     int y = fa[x], z = fa[y], kx = pd(x), ky = pd(y);     if (z) ch[z][ky] = x;     fa[x] = z, fa[y] = x, fa[ch[x][kx ^ 1]] = y;     ch[y][kx] = ch[x][kx ^ 1];     ch[x][kx ^ 1] = y;     pushup(y), pushup(x);     if (z) pushup(z);   }   inline void splay(int x) {     static int sta[N], tp;     sta[tp = 1] = x;     for (int y = x; fa[y]; y = fa[y]) sta[++tp] = fa[y];     while (tp) pushdown(sta[tp--]);     for (; fa[x]; rotate(x))       if (fa[fa[x]]) rotate((pd(x) ^ pd(fa[x])) ? x : fa[x]);     pushup(rt = x);   }   inline long long getv(int k) {     int x = rt;     while (1) {       if (sz[ch[x][0]] + 1 == k) {         splay(x);         return val[x];       }       if (sz[ch[x][0]] >= k)         x = ch[x][0];       else         k -= sz[ch[x][0]] + 1, x = ch[x][1];     }   }   inline long long getmx(int x) {     if (!x) return -1e18;     pushdown(x);     return std::max(val[x], std::max(getmx(ch[x][0]), getmx(ch[x][1])));   }   int main() {     n = read();     sz[1] = rt = cnt = 1;     for (register int i = 1, endi = n; i <= endi; ++i) {       int a = read();       int lp = 0, rp = i - 2, ans = i - 1;       while (lp <= rp) {         int mid = (lp + rp) >> 1;         if (getv(mid + 1) + (mid + 1LL) * a > getv(mid + 2))           rp = (ans = mid) - 1;         else           lp = mid + 1;       }       getv(ans + 1);       fa[++cnt] = rt, val[cnt] = val[rt], ch[cnt][1] = ch[rt][1];       fa[ch[rt][1]] = cnt;       ch[rt][1] = cnt;       modify(cnt, a, 1LL * a * ans);     }     printf( %lld n , getmx(rt));     return 0;   }   