#P1832D2. Red-Blue Operations (Hard Version)

    ID: 8437 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 9 Uploaded By: Tags>binary searchconstructive algorithmsgreedyimplementationmath*2400

Red-Blue Operations (Hard Version)

No submission language available for this problem.

Description

The only difference between easy and hard versions is the maximum values of nn and qq.

You are given an array, consisting of nn integers. Initially, all elements are red.

You can apply the following operation to the array multiple times. During the ii-th operation, you select an element of the array; then:

  • if the element is red, it increases by ii and becomes blue;
  • if the element is blue, it decreases by ii and becomes red.

The operations are numbered from 11, i. e. during the first operation some element is changed by 11 and so on.

You are asked qq queries of the following form:

  • given an integer kk, what can the largest minimum in the array be if you apply exactly kk operations to it?

Note that the operations don't affect the array between queries, all queries are asked on the initial array aa.

The first line contains two integers nn and qq (1n,q21051 \le n, q \le 2 \cdot 10^5) — the number of elements in the array and the number of queries.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1091 \le a_i \le 10^9).

The third line contains qq integers k1,k2,,kqk_1, k_2, \dots, k_q (1kj1091 \le k_j \le 10^9).

For each query, print a single integer — the largest minimum that the array can have after you apply exactly kk operations to it.

Input

The first line contains two integers nn and qq (1n,q21051 \le n, q \le 2 \cdot 10^5) — the number of elements in the array and the number of queries.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1091 \le a_i \le 10^9).

The third line contains qq integers k1,k2,,kqk_1, k_2, \dots, k_q (1kj1091 \le k_j \le 10^9).

Output

For each query, print a single integer — the largest minimum that the array can have after you apply exactly kk operations to it.

Sample Input 1

4 10
5 2 8 4
1 2 3 4 5 6 7 8 9 10

Sample Output 1

3 4 5 6 7 8 8 10 8 12

Sample Input 2

5 10
5 2 8 4 4
1 2 3 4 5 6 7 8 9 10

Sample Output 2

3 4 5 6 7 8 9 8 11 8

Sample Input 3

2 5
2 3
10 6 8 1 3

Sample Output 3

10 7 8 3 3