Robot Upgrades
시간 제한1초메모리 제한2048 MB
N개의 부품에 0에서 M까지 업그레이드 횟수를 배정하되, i회 이상 업그레이드된 부품 수가 A_i 이하가 되도록 하는 배치의 수를 센다.
문제
The Kingdom of ICPC is being attacked by evil balloons! Fortunately, Morgan the robot is ready to defend the kingdom. In order to strengthen his power, there are parts, numbered from to , that can be upgraded. Each part can be upgraded to times (inclusive).
In order to save resources, there are restrictions, numbered from to , in upgrading Morgan. For restriction , the number of parts that are upgraded at least times should not exceed .
While planning on what upgrade should be applied to Morgan, Adrian wonders how many different upgrade configurations that satisfy all of the given restrictions. Two configurations are different if and only if there exists at least one part with a different number of upgrades applied to that part. Since the answer can be large, find the answer modulo .
입력
Input begins with two integers (; ) representing the number of parts and the number of restrictions, respectively. The next line contains integers () representing the given restrictions. The integers in are given in non-increasing order, i.e. .
출력
Output an integer in a single line, representing the number of different upgrade configurations that satisfy all of the given restrictions modulo .