Maximal Sum

For each query value b_j, find the maximum sum of a contiguous segment of a whose elements are all at least b_j, or 0 if none exists.

Medium7SortingDivide and conquerDynamic programmingPrefix sumNo attempts yetTime limit2sMemory limit512 MB

Problem

Marty wants to get back to the future from the past. The computer in his time machine is broken, so he has to work out the numbers himself and type them in.

Marty has two integer arrays: a[1..n]a[1..n] of length nn and b[1..m]b[1..m] of length mm. For each bjb_j he needs the largest possible sum al+al+1++ara_l + a_{l+1} + \cdots + a_r over the segments a[l..r]a[l..r] whose elements are all greater than or equal to bjb_j.

A segment is never empty, so lrl \le r holds and the largest sum can be negative. If no element of aa is greater than or equal to bjb_j, no segment satisfies the condition.

Input

The first line contains two integers nn and mm (1n,m1051 \le n, m \le 10^5), the sizes of the arrays aa and bb.

The second line contains nn integers aia_i (109ai109-10^9 \le a_i \le 10^9).

The third line contains mm integers bjb_j (109bj109-10^9 \le b_j \le 10^9).

Output

Print mm integers on one line, separated by single spaces. The jj-th number is the largest segment sum for bjb_j, or 00 if no segment satisfies the condition.