문제
The grass has dried up in Farmer John's pasture due to a drought. After hours of despair and contemplation, FJ comes up with the brilliant idea of purchasing corn to feed his precious cows.
FJ’s () cows are arranged in a line such that the th cow in line has a non-negative integer hunger level of . As FJ’s cows are social animals and insist on eating together, the only way FJ can decrease the hunger levels of his cows is to select two adjacent cows and and feed each of them a bag of corn, causing each of their hunger levels to decrease by one.
FJ wants to feed his cows until all of them have the same non-negative hunger level. Although he doesn't know his cows' exact hunger levels, he does know an upper bound on the hunger level of each cow; specifically, the hunger level of the -th cow is at most ().
Your job is to count the number of -tuples of hunger levels that are consistent with these upper bounds such that it is possible for FJ to achieve his goal, modulo .
입력
The first line contains .
The second line contains .
출력
The number of -tuples of hunger levels modulo .
예제 입력 1
3
9 11 7
예제 출력 1
241
예제 입력 2
4
6 8 5 9
예제 출력 2
137
점수
is even in even-numbered tests and odd in odd-numbered tests.
Tests 3 and 4 satisfy and .Tests 5 through 10 satisfy and .Tests 11 through 20 satisfy no further constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인