Alan has a large number of papers to write. Being a good student majoring in Computer Science, his brain is powerful enough to write at most papers at the same time.
At any time, Alan can start to write a new paper if the number of papers he has started but not yet finished is less than . Once he starts to write a new paper in the
-th hour, he will use the next
consecutive hours to complete it. In other words, he will finish this new paper in the
-th hour, where
is the number of papers that Alan has started and has not yet finished (doesn't include the new paper) and
is a non-decreasing array.
For example, if Alan needs to write papers and
. Define an array
as the time when the paper will be completed for the
papers he is writing currently. One possible strategy can be described as follows:
At first, Alan begins to write papers, so that
.
At the end of the first hour, Alan begins to write the third paper, so that .
At the end of the second hour, Alan finishes his first paper, so becomes
. At the same time, he begins to write his fourth paper, so
.
At the end of the fourth hour, Alan finishes his second paper, so becomes
. At the same time, he begins to write his fifth paper, so
.
At the end of the sixth hour, Alan finishes his third paper, so becomes
.
At the end of the seventh hour, Alan finishes his fourth paper, so becomes
.
At the end of the ninth hour, Alan finishes his fifth paper, so becomes
.
So, it takes hours for Alan to finish all his
papers if he takes such action.
Doesn't know how many papers he needs to write, Alan will ask you times and each time he will give you a positive integer
, which is the number of papers. To finish his homework as fast as possible and then go to play the computer games, Alan wants to know the minimum time he needs. You must tell him how many hours he needs to complete all his papers if his strategy is optimal.
The first line of the input contains a single integer
![]()
, denoting the number of papers that Alice can write at the same time.
The second line contains
integers
![]()
, where
denotes the number of hours it will take Alice to finish this paper if he has
started and not finished papers currently. It is guaranteed that
.
The third line contains a single integer
![]()
, denoting the number of queries.
For the next
lines, each line contains a single integer
![]()
, indicating the number of papers he needs to finish.
For each query, output a single integer, indicating the minimum number of hours that Alice needs if he wants to finish all hispapers.
In the first example:
For
, Alan can write all his
papers together at the beginning, and these
papers will be completed in the second, fourth, and fifth hour, respectively. So, that will take him
hours to finish three papers.
For
, the situation is the same as mentioned in the statement.