Under construction

Still being built. Things may change

Garden

Time limit3sMemory limit512 MB

Summary
Given sorted tree heights, each day the leftmost tree with the smallest positive gap to its right grows by 1. For each K, find the tallest minus shortest height after K days.
Level

Hard8 of 10

Topics
Greedy, Binary search, Array
Solved
No attempts yet

Problem

Hyeonwook's garden in front of his house has NN trees (1≤N≤3⋅1051 \le N \le 3 \cdot 10^5). Each tree height is an integer from 11 to 10910^9, and the trees are planted so that their heights are non-decreasing. If HiH_i is the height of the ii-th tree, then Hi≤Hi+1H_i \le H_{i+1} always holds.

Each day, a tree grows by 11 if it meets both conditions:

  • It is strictly shorter than the tree directly to its right (Hi<Hi+1H_i < H_{i+1}).
  • Among such trees, the height difference with the tree directly to its right is the smallest.

If several trees qualify, only the leftmost one grows. In other words, at most one tree grows per day. For example, suppose the heights are 1,3,4,5,5,71, 3, 4, 5, 5, 7. The trees with the smallest difference to their right neighbor are the 2nd and 3rd trees, both with difference 11. Of these, the leftmost is the 2nd tree, so its height grows by 11.

Starting today, Hyeonwook wants to know the difference between the tallest and the shortest tree after KK days (1≤K≤10121 \le K \le 10^{12}). Given QQ queries (1≤Q≤3⋅1051 \le Q \le 3 \cdot 10^5), write a program that answers each query.

Input

The first line contains NN and QQ (1≤N,Q≤3⋅1051 \le N, Q \le 3 \cdot 10^5).

The second line contains NN tree heights HiH_i separated by spaces (1≤Hi≤1091 \le H_i \le 10^9). The input always satisfies Hi≤Hi+1H_i \le H_{i+1}.

Each of the next QQ lines contains one query. Every KK is an integer with 1≤K≤10121 \le K \le 10^{12}.

Output

For each query, print on its own line the difference between the heights of the tallest and the shortest tree after KK days.

Examples1

  1. Example 1

    Input
    5 6
    1 3 3 4 5
    2
    3
    5
    6
    8
    10
    
    Expected output
    4
    4
    4
    3
    1
    0