Bitaro’s Travel

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

There is a very long road in JOI City, which can be considered as the real number line. A position on the road is represented by a real number coordinate. In JOI City, there are NN sightseeing spots along the road, numbered from 11 to NN in ascending order of the coordinates. The coordinate of the ii-th sightseeing spot (1iN1 ≤ i ≤ N) is X_iX\_i.

Bitaro will visit all the sightseeing spots in JOI City. Since “greedy” is the slogan of his life, he will repeat the following procedures until he visits all the sightseeing spots.

  • Let xx be Bitaro’s current coordinate. Among the sightseeing spots he has not yet visited, take the sightseeing spot ii where the distance xX_i|x − X\_i| from Bitaro’s current position takes a minimum value. Then Bitaro moves to the position of the sightseeing spot i, and visits it. If there are more than one such sightseeing spots, he moves to the sightseeing spot whose coordinate is smaller than the others. Here, t|t| is the absolute value of tt.

However, thanks to long years of experience, Bitaro knows that if he moves by repeating the above procedures, the total traveling distance may be longer than he expected. Since the total traveling distance varies according to the starting coordinate, he wants to know the total traveling distance until he visits all the sightseeing spots if he starts from each of QQ candidates of starting coordinates S_1,S_2,,S_QS\_1, S\_2, \dots , S\_Q.

To help Bitaro, write a program which calculates the total traveling distance if he starts from each of the candidates of starting coordinates, given information of JOI City and candidates of starting coordinates.

입력

Read the following data from the standard input.

NN

X_1X\_1 X_2X\_2 \cdots X_NX\_N

QQ

S_1S\_1

S_2S\_2

\vdots

S_QS\_Q

출력

Write QQ lines to the standard output. The jj-th line (1jQ1 ≤ j ≤ Q) of output should contain the total traveling distance if Bitaro starts from the coordinate S_jS\_j.

제한

  • 1N200,0001 ≤ N ≤ 200\\,000.
  • 1Q200,0001 ≤ Q ≤ 200\\,000.
  • 0X_i1090 ≤ X\_i ≤ 10^9 (1iN1 ≤ i ≤ N).
  • X_i<X_i+1X\_i < X\_{i+1} (1iN11 ≤ i ≤ N - 1).
  • 0S_j1090 ≤ S\_j ≤ 10^9 (1jQ1 ≤ j ≤ Q).
  • Given values are all integers.