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[(int)2e5+1]; 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<=(int)2e5;++i) { if (A[i]==0) continue; for (int a=i;a