#include #include #include using namespace std; const int N=5e5+10; typedef long long ll; inline int read() { int s = 0, t = 1; char c = getchar(); while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); } while( isdigit(c) ) s = s * 10 + c - 48, c = getchar(); return s * t; } int n, head, tail; ll sum[N], Sum[N], a[N], ans; struct node{ ll x,y; node(ll X=0,ll Y=0){x=X;y=Y;} node operator - (node a){return node(x-a.x,y-a.y);} __int128 operator * (node a){return (__int128)x*a.y-(__int128)y*a.x;} }p[N],q[N],Q[N],A[N]; ll calc(node p,node q){return p.x*q.x+p.y+q.y;} bool cmp(node x,node y){return x.x>1; solve(l,mid); solve(mid+1,r); head=1;tail=0; for (int i=l;i<=mid;i++){ for (;tail>1&&(Q[tail]-Q[tail-1])*(p[i]-Q[tail])>0;tail--); Q[++tail]=p[i]; } for (int i=mid+1;i<=r;i++){ for (;head