func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   int a[210000];   long long sum[210000];   long long calc_move(int from, int to) {     return a[from] * 1ll * (to - from) - (sum[to] - sum[from]);   }   long long crossover(int from, int to) {     long long headstart = calc_move(from, to);     if (headstart < 0) return to;     return to + 1 + headstart / (a[to] - a[from]);   }   long long solve() {     long long ret = 0;     deque<int> q;     for (int(i) = 0; (i) < (int)(n); (i)++)       sum[i] = (i == 0 ? 0 : sum[i - 1]) + a[i];     int largest_so_far = -100000000;     for (int(i) = 0; (i) < (int)(n); (i)++) {       if (a[i] > largest_so_far) {         while (q.size() >= 2 && crossover(q[0], q[1]) >= crossover(q[0], i))           q.pop_back();         q.push_back(i);         largest_so_far = a[i];       }       while (q.size() >= 2 && crossover(q[0], q[1]) <= i) q.pop_front();       ret = max(ret, calc_move(q[0], i));     }     return ret;   }   int main() {     long long start_char = 0;     scanf( %d , &n);     for (int(i) = 0; (i) < (int)(n); (i)++) {       scanf( %d , &a[i]);       start_char += (i + 1) * 1ll * a[i];     }     long long best_delta = solve();     reverse(a, a + n);     for (int(i) = 0; (i) < (int)(n); (i)++) a[i] = -a[i];     best_delta = max(best_delta, solve());     printf( %lld n , start_char + best_delta);   }   