#P1610D. Not Quite Lee
Not Quite Lee
No submission language available for this problem.
Description
Lee couldn't sleep lately, because he had nightmares. In one of his nightmares (which was about an unbalanced global round), he decided to fight back and propose a problem below (which you should solve) to balance the round, hopefully setting him free from the nightmares.
A non-empty array is called good, if there exist integer sequences which satisfy the following properties:
- The -th sequence consists of consecutive integers (for example if then the -th sequence can be or but not or ).
- Assuming the sum of integers in the -th sequence is , we want to be equal to .
You are given an array . It has nonempty subsequences. Find how many of them are good.
As this number can be very large, output it modulo .
An array is a subsequence of an array if can be obtained from by deletion of several (possibly, zero or all) elements.
The first line contains a single integer () — the size of array .
The second line contains integers () — elements of the array.
Print a single integer — the number of nonempty good subsequences of , modulo .
Input
The first line contains a single integer () — the size of array .
The second line contains integers () — elements of the array.
Output
Print a single integer — the number of nonempty good subsequences of , modulo .
Samples
Note
For the first test, two examples of good subsequences are and :
For we can use as the first sequence and as the second. Note that subsequence appears twice in , so we have to count it twice.

For the following sequences would satisfy the properties: , , and