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(); } void run() { Scanner sc=new Scanner(System.in); int N=sc.nextInt(); int[] A=new int[N]; int[] s=new int[(int)2e5+1]; long ans=0; for (int i=0;i=0;--i) { s[i]+=s[i+1]; } for (int i=0;i