atcoder#ABC255D. [ABC255D] ±1 Operation 2

[ABC255D] ±1 Operation 2

Score : 400400 points

Problem Statement

You are given a sequence of length NN: A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N). The following action on this sequence is called an operation.

  • First, choose an integer ii such that 1iN1 \le i \le N.
  • Next, choose and do one of the following.- Add 11 to AiA_i.
    • Subtract 11 from AiA_i.

Answer QQ questions. The ii-th question is the following.

  • Consider performing zero or more operations to change every element of AA to XiX_i. Find the minimum number of operations required to do so.

Constraints

  • All values in input are integers.
  • 1N,Q2×1051 \le N,Q \le 2 \times 10^5
  • 0Ai1090 \le A_i \le 10^9
  • 0Xi1090 \le X_i \le 10^9

Input

Input is given from Standard Input in the following format:

NN QQ

A1A_1 A2A_2 \dots ANA_N

X1X_1

X2X_2

\vdots

XQX_Q

Output

Print QQ lines. The ii-th line should contain the answer to the ii-th question as an integer.

5 3
6 11 2 5 5
5
20
0
10
71
29

We have A=(6,11,2,5,5)A=(6,11,2,5,5) and three questions in this input.

For the 11-st question, you can change every element of AA to 55 in 1010 operations as follows.

  • Subtract 11 from A1A_1.
  • Subtract 11 from A2A_2 six times.
  • Add 11 to A3A_3 three times.

It is impossible to change every element of AA to 55 in 99 or fewer operations.

For the 22-nd question, you can change every element of AA to 2020 in 7171 operations.

For the 33-rd question, you can change every element of AA to 00 in 2929 operations.

10 5
1000000000 314159265 271828182 141421356 161803398 0 777777777 255255255 536870912 998244353
555555555
321654987
1000000000
789456123
0
3316905982
2811735560
5542639502
4275864946
4457360498

The output may not fit into 3232-bit integers.