import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; import java.util.Stack; class Main { public static void main(String[] $) { new Main().run(); } class Seg { int n=1<<20; long[] v=new long[2*n-1]; long[] lazy=new long[2*n-1]; final long INF=Long.MAX_VALUE/3; long query(int a,int b,long add) { return query(0,n,a,b,0,add); } long query(int l,int r,int a,int b,int k,long add) { if (b<=l||r<=a) return INF; if (a<=l&&r<=b) { lazy[k]+=add; v[k]+=add; return v[k]; } long vl=query(l,(l+r)/2,a,b,2*k+1,add); long vr=query((l+r)/2,r,a,b,2*k+2,add); v[k]=Math.min(v[2*k+1], v[2*k+2]); return lazy[k]+Math.min(vl, vr); } } void run() { Scanner sc=new Scanner(System.in); PrintWriter pw=new PrintWriter(System.out); int N=sc.nextInt(); Seg seg=new Seg(); for (int i=0;i