{"raw_statement":[{"iden":"problem statement","content":"$N$ people, numbered $1,2,\\ldots ,N$, are going to stand on the number line. Let's denote by $x_i$ the coordinate the Person $i$ stands at. Then, $x_i$ should be an integer satisfying $L_i \\leq x_i \\leq R_i$. Multiple people can occupy the same coordinate.\nWe define the **dissatisfaction level** as the following formula:\n\n> $\\displaystyle\\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N}|x_j-x_i|$\n\nFind the minimum possible value of the dissatisfaction level."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 3 \\times 10^5$\n*   $1 \\leq L_i \\leq R_i \\leq 10^7 \\,(1 \\leq i \\leq N)$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$L_1$ $R_1$\n$L_2$ $R_2$\n$\\vdots$\n$L_N$ $R_N$"},{"iden":"sample input 1","content":"3\n1 3\n2 4\n5 6"},{"iden":"sample output 1","content":"4\n\nIf we let $x_1=3,x_2=4,x_3=5$, we get the dissatisfaction level of $4$. We cannot make it $3$ or less, so the answer is $4$."},{"iden":"sample input 2","content":"3\n1 1\n1 1\n1 1"},{"iden":"sample output 2","content":"0"},{"iden":"sample input 3","content":"6\n1 5\n2 4\n1 1\n4 4\n3 6\n3 3"},{"iden":"sample output 3","content":"15"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}