City Flooding

Time limit: 0.1s Memory limit: 128MB Input: Output:

William is playing a city simulation game: the main objective is to save the mayor’s life in the event of natural disasters \dots and the weather forecast just warned William about an imminent flooding!

The city can be seen as a straight line: there are NN positions numbered from 00 to N1N - 1. The mayor’s house is in position KK. During the flooding, LL liters of water will flow from the left corner to position 00 first, then to position 11 and so on. In order to stop the water from flooding the mayor’s home, you need to place N1N - 1 manholes in every position except the one in which the house of the mayor is located. Luckily, you have exactly N1N - 1 manholes left in the game inventory, however, they are all different. Some are able to “subtract” more water than others: no two manholes will subtract the same amount!

For example, let’s say that L=100L = 100 liters of water will rain down during the flooding. Moreover, let’s assume that the city has N=5N = 5 total positions (numbered from 00 to 44), and that K=3K = 3 is the position of the mayor’s house. In this case, we would have N1=4N - 1 = 4 manholes in our inventory. Let’s say that the 44 manholes are able to remove, respectively: 1515, 8080, 2020 and 5050 liters of water.

In this case, we can see that there are only 66 ways to arrange the manholes so that some water will hit the mayor’s home (indicated with a \star). To be precise, 100100 - (15+20+5015 + 20 + 50) = 1515 liters of water will reach his home.

So, the number of bad manhole arrangements is 66. Since the total number of arrangements is 4!=244! = 24, we can deduce that the answer for this case is 246=1824 - 6 = 18.

Compute how many ways William can put the N1N - 1 manholes in such a way that will keep the mayor’s house dry during the flooding.

Input data

The first line contains a single integer: LL. The second line contains two integers: NN and KK. The third line contains N1N - 1 integers V0,V1,,VN1V_0, V_1, \dots, V_{N-1}: the “capacity” of the manholes.

Output data

You need to write a single line with an integer: the number of good manhole arrangements. Since this number can be huge, just print the remainder when dividing it by 10 00710 \ 007.

Constraints and clarifications

  • 1L1 0001 \leq L \leq 1 \ 000.
  • 2N1002 \leq N \leq 100.
  • 0KN10 \leq K \leq N - 1.
  • 0Vi1 0000 \leq V_i \leq 1 \ 000 for each i=0N2i = 0 \dots N - 2.
  • All ViV_i values are different.
# Score Constraints
1 5 Examples
2 15 K=N1K = N - 1, that is, the mayor lives in the last position.
3 20 N8N \leq 8
4 30 N16N \leq 16
5 30 No additional limitations.

Example 1

stdin

100
5 3
15 80 20 50

stdout

18

Explanation

The first sample case is the one described in the task statement.

Example 2

stdin

100
10 5
34 30 16 9 18 14 27 10 15

stdout

5415

Explanation

In the second sample case there are 155 520155 \ 520 valid combinations. Since we are requested to print only the remainder of the division by 10 00710 \ 007, the answer is 155 520155 \ 520 % 10 00710 \ 007 = 5 4155 \ 415.

Log in or sign up to be able to send submissions!