P13616 [CodeChef] numpath
普及
题目描述

The Head Chef is interested in studying interactions between his chefs . There are N chefs with ids 1 to N . Each chef trusts some of the other chefs . The relation of trust is one way . Also , a chef may trust chefs only with ids strictly greater than his/her id .A chef with id = i , trusts the chefs with next ni id's.
The Head Chef wants to know given a chef B and a set of chefs S, how many lines of trust exist between each element of S and B . A line of trust between chefs A and B is a sequence of chefs a1 ... ak starting at A ( a1 = A )and finishing at B (Ak = B) such that Ai trusts A(i+1) for all i ( 1 to k-1) . Two lines of trust are different if they have a different chef at the some position in the line .

Since the answer may be quite large , output it modulo 1000000007 .

Input

The first line contains a two space seperated integers N and B denoting the number of chefs and the target chef for whom the lines of trust have to be calculated.
The next N lines contains an integer ni denoting the number of chefs which are trusted by the chef with id = i .
The next line contains a single integer Q denoting the number of queries
The next Q lines contain elements of set S .

Output

Output a single line for each query containing the answer to the query.

Constraints

1 ≤ N ≤ 200000
1 ≤ B ≤ N
1 ≤ Q ≤ 100000
1 ≤ Each element of set S < B
1 ≤ i + ni ( for i = 1 to N ) ≤ N
0 ≤ ni ( for i = 1 to N ) ≤ N - 1

Example
Input:
3 3
2
1
0
2
1
2
Output:
2
1

Explanation
Example case 1. The lines of trust between 1 and 3 are
1 , 3
1 , 2 ,3
There is one line of trust between 2 and 3 which is
2 3

输入格式

见题面

输出格式

见题面

样例输入
3 3 2 1 0 2 1 2
样例输出
2 1