Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

binary search

greedy

implementation

math

*2100

No tag edit access

The problem statement has recently been changed. View the changes.

×
D1. Red-Blue Operations (Easy Version)

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputThe only difference between easy and hard versions is the maximum values of $$$n$$$ and $$$q$$$.

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

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

- if the element is red, it increases by $$$i$$$ and becomes blue;
- if the element is blue, it decreases by $$$i$$$ and becomes red.

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

You are asked $$$q$$$ queries of the following form:

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

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

Input

The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n, q \le 1000$$$) — the number of elements in the array and the number of queries.

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).

The third line contains $$$q$$$ integers $$$k_1, k_2, \dots, k_q$$$ ($$$1 \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 $$$k$$$ operations to it.

Examples

Input

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

Output

3 4 5 6 7 8 8 10 8 12

Input

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

Output

3 4 5 6 7 8 9 8 11 8

Input

2 5 2 3 10 6 8 1 3

Output

10 7 8 3 3

Codeforces (c) Copyright 2010-2023 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/30/2023 19:47:42 (j2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|