QOJ.ac

QOJ

حد الوقت: 6 s حد الذاكرة: 512 MB مجموع النقاط: 10 الصعوبة: [عرض]

#2120. Modulo [B]

الإحصائيات

Mopadulo numbers are numbers whose remainder when divided by $p$ is even. We do not know any large prime numbers other than $10^9 + 7$, so we will only deal with mopadulo $1\,000\,000\,007$ numbers.

Calculate the number of ways to partition a given sequence of numbers $a_1, a_2, \dots, a_n$ into intervals such that the sum of numbers in each interval is a mopadulo $1\,000\,000\,007$ number. In such a partition, every element of the sequence must belong to exactly one interval. Since the number of such partitions can be very large, it is sufficient to provide its remainder when divided by (what else?) $10^9 + 7$.

Input

The first line of input contains a single integer $n$ ($1 \le n \le 300\,000$), representing the length of the given sequence.

The second line of input contains a sequence of $n$ integers $a_1, a_2, \dots, a_n$ ($0 \le a_i < 10^9 + 7$).

Output

The output should contain a single integer representing the remainder of the number of valid partitions of the sequence $a_1, a_2, \dots, a_n$ when divided by $10^9 + 7$.

Examples

Input 1

4
1000000006 1 5 1000000004

Output 1

3

Note

Explanation of the example: The valid partitions into intervals are: $[1000000006, 1, 5, 1000000004]$ $[1000000006, 1], [5, 1000000004]$ * $[1000000006], [1, 5], [1000000004]$

Subtasks

  • In some test groups, $a_i \le 100$.
  • In other test groups, $n \le 3000$.

In both of the above cases, there is at least one such group.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.