Circus

Find the smallest starting hold depth on a temporary rope at D that reaches distance M by hopping between ropes within swing range.

Hard9Shortest pathSegment treeSortingNo attempts yetTime limit2sMemory limit512 MB

Problem

A new circus act uses very long ropes that hang from the flat ceiling of the circus hall. The entrance of the hall and all the ropes lie on one straight line. The ceiling is 101810^{18} units high, and every rope hangs freely down to the ground. The performer moves from rope to rope and has to get at least MM units away from the entrance.

There are NN ropes. Rope ii hangs at the point that is PiP_i units from the entrance, measured along the ceiling.

The performer is careful and never jumps wildly. Suppose she holds rope ii at a point SS units below the ceiling. She can swing on the rope she is holding. If she reaches a point at least MM units from the entrance while swinging, her task is done. While swinging she can grab another rope that hangs at most SS units away from the rope she holds. Formally, she can grab rope jj if PiPjS|P_i - P_j| \le S. She now holds rope ii and rope jj at the same time. From there she climbs rope ii while keeping rope jj in her hands. Once she reaches the point where rope ii touches the ceiling, rope jj is pulled tight along the ceiling. From that moment she continues her movement holding rope jj at a point PiPj|P_i - P_j| units below the ceiling.

The manager wants to hang one more rope, a temporary one, at the point that is DD units from the entrance along the ceiling. The act starts on that rope. The performer has to travel from it to the far end of the hall, at least MM units from the entrance. While she moves from rope to rope, the temporary rope behaves exactly like a regular rope. Write a program that computes the smallest distance below the ceiling at which the performer must hold the temporary rope so that she can finish her task.

Consider three ropes hanging 0, 3 and 6 units from the entrance, with the target M=8M = 8. The temporary rope is 4 units from the entrance. If the performer holds the temporary rope (drawn bold) 3 units below the ceiling, she can swing and grab the rope that is 6 units from the entrance. After grabbing it she climbs the temporary rope to the ceiling, and she then holds the rope at 6 at a point 64=26 - 4 = 2 units below the ceiling. Swinging again from there, she reaches the target point 8 units from the entrance.

The manager has several candidate places for the temporary rope and wants the answer for each of them.

Input

The first line contains the number of ropes NN and the target distance MM, separated by a space.

Each of the next NN lines contains one rope position PiP_i.

The next line contains the number of queries QQ.

Each of the last QQ lines contains one position DD of the temporary rope.

Output

Print QQ lines, one answer per query, in the order the queries are given. Each line holds the smallest distance below the ceiling at which the performer must hold the temporary rope to finish her task.

Constraints

  • 1N1000001 \le N \le 100000
  • 1Q1000001 \le Q \le 100000
  • 1M1091 \le M \le 10^9
  • 0Pi<M0 \le P_i < M
  • 0D<M0 \le D < M
  • All numbers in the input are integers.
  • Two different ropes may hang at the same position.

Explanation

Take the ropes at 0, 3 and 6 with M=8M = 8.

For a temporary rope at 4 the answer is 2. Holding it 2 units below the ceiling is enough, because 46=2|4 - 6| = 2 lets the performer grab the rope at 6; after climbing the temporary rope she holds the rope at 6 two units below the ceiling and reaches 6+2=86 + 2 = 8. Another route runs from 4 to 0, then to 3, then to 6, and then to 8, but it forces her to hold the temporary rope 4 units below the ceiling at the start.

For a temporary rope at 5 the answer is 3. Here she reaches the target straight from the temporary rope, without touching any other rope.