#558
Unrated
Drought
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

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 NN (1N1001 \leq N \leq 100) cows are arranged in a line such that the iith cow in line has a non-negative integer hunger level of hih_i. 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 ii and i+1i+1 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 hih_i of the ii-th cow is at most HiH_i (0Hi10000\le H_i\le 1000).

Your job is to count the number of NN-tuples of hunger levels [h1,h2,,hN][h_1,h_2,\ldots,h_N] that are consistent with these upper bounds such that it is possible for FJ to achieve his goal, modulo 109+710^9+7.

입력

The first line contains NN.

The second line contains H1,H2,,HNH_1,H_2,\ldots,H_N.

출력

The number of NN-tuples of hunger levels modulo 109+710^9+7.

예제 입력 1

3
9 11 7

예제 출력 1

241

예제 입력 2

4
6 8 5 9

예제 출력 2

137

점수

NN is even in even-numbered tests and odd in odd-numbered tests.

Tests 3 and 4 satisfy N6N\le 6 and Hi10H_i \le 10.Tests 5 through 10 satisfy N50N\le 50 and Hi100H_i \le 100.Tests 11 through 20 satisfy no further constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.