Drought

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

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 h_ih\_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 h_ih\_i of the ii-th cow is at most H_iH\_i (0H_i10000\le H\_i\le 1000).

Your job is to count the number of NN-tuples of hunger levels \[h_1,h_2,,h_N]\[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 H_1,H_2,,H_NH\_1,H\_2,\ldots,H\_N.

출력

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