{"raw_statement":[{"iden":"problem statement","content":"You are given a sequence of length $N$: $A=(A_1,A_2,\\dots,A_N)$. The following action on this sequence is called an _operation_.\n\n*   First, choose an integer $i$ such that $1 \\le i \\le N$.\n*   Next, choose and do one of the following.\n    *   Add $1$ to $A_i$.\n    *   Subtract $1$ from $A_i$.\n\nAnswer $Q$ questions.  \nThe $i$\\-th question is the following.\n\n*   Consider performing zero or more operations to change every element of $A$ to $X_i$. Find the minimum number of operations required to do so."},{"iden":"constraints","content":"*   All values in input are integers.\n*   $1 \\le N,Q \\le 2 \\times 10^5$\n*   $0 \\le A_i \\le 10^9$\n*   $0 \\le X_i \\le 10^9$"},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $Q$\n$A_1$ $A_2$ $\\dots$ $A_N$\n$X_1$\n$X_2$\n$\\vdots$\n$X_Q$"},{"iden":"sample input 1","content":"5 3\n6 11 2 5 5\n5\n20\n0"},{"iden":"sample output 1","content":"10\n71\n29\n\nWe have $A=(6,11,2,5,5)$ and three questions in this input.\nFor the $1$\\-st question, you can change every element of $A$ to $5$ in $10$ operations as follows.\n\n*   Subtract $1$ from $A_1$.\n*   Subtract $1$ from $A_2$ six times.\n*   Add $1$ to $A_3$ three times.\n\nIt is impossible to change every element of $A$ to $5$ in $9$ or fewer operations.\nFor the $2$\\-nd question, you can change every element of $A$ to $20$ in $71$ operations.\nFor the $3$\\-rd question, you can change every element of $A$ to $0$ in $29$ operations."},{"iden":"sample input 2","content":"10 5\n1000000000 314159265 271828182 141421356 161803398 0 777777777 255255255 536870912 998244353\n555555555\n321654987\n1000000000\n789456123\n0"},{"iden":"sample output 2","content":"3316905982\n2811735560\n5542639502\n4275864946\n4457360498\n\nThe output may not fit into $32$\\-bit integers."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}