{"raw_statement":[{"iden":"problem statement","content":"You are given a permutation $P = (P_1, P_2, \\ldots, P_N)$ of $(1, 2, \\ldots, N)$. Takahashi can repeatedly perform the following operation on $P$ (possibly zero times):\n\n*   Choose an integer $i$ satisfying $1 \\leq i \\leq N-1$. Pay a cost of $i$, and swap $P_i$ and $P_{i+1}$.\n\nFind the minimum total cost required to sort $P$ in ascending order."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 2 \\times 10^5$\n*   $(P_1, P_2, \\ldots, P_N)$ is a permutation of $(1, 2, \\ldots, N)$.\n*   All input values are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$P_1$ $P_2$ $\\ldots$ $P_N$"},{"iden":"sample input 1","content":"3\n3 2 1"},{"iden":"sample output 1","content":"4\n\nTakahashi can sort $P$ in ascending order as follows:\n\n*   Pay a cost of $1$ and swap $P_1 = 3$ and $P_2 = 2$. Now, $P = (2, 3, 1)$.\n*   Pay a cost of $2$ and swap $P_2 = 3$ and $P_3 = 1$. Now, $P = (2, 1, 3)$.\n*   Pay a cost of $1$ and swap $P_1 = 2$ and $P_2 = 1$. Now, $P = (1, 2, 3)$.\n\nThe total cost for these operations is $4$, which is the minimum possible."},{"iden":"sample input 2","content":"5\n2 4 1 3 5"},{"iden":"sample output 2","content":"6"},{"iden":"sample input 3","content":"2\n1 2"},{"iden":"sample output 3","content":"0"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}