Mod i

AtCoder
IDabc207_e
Time2000ms
Memory256MB
Difficulty
Given is a sequence $A$ of $N$ numbers. Find the number of ways to separate $A$ into some number of non-empty contiguous subsequence $B_1, B_2, \ldots, B_k$ so that the following condition is satisfied: * For every $i\ (1 \leq i \leq k)$, the sum of elements in $B_i$ is divisible by $i$. Since the count can be enormous, print it modulo $(10^9+7)$. ## Constraints * $1 \leq N \leq 3000$ * $1 \leq A_i \leq 10^{15}$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ $A_1$ $A_2$ $\ldots$ $A_N$ [samples]
Samples
Input #1
4
1 2 3 4
Output #1
3

We have three ways to separate the sequence, as follows:

*   $(1),(2),(3),(4)$
*   $(1,2,3),(4)$
*   $(1,2,3,4)$
Input #2
5
8 6 3 3 3
Output #2
5
Input #3
10
791754273866483 706434917156797 714489398264550 918142301070506 559125109706263 694445720452148 648739025948445 869006293795825 718343486637033 934236559762733
Output #3
15

The values in input may not fit into a $32$\-bit integer type.
API Response (JSON)
{
  "problem": {
    "name": "Mod i",
    "description": {
      "content": "Given is a sequence $A$ of $N$ numbers. Find the number of ways to separate $A$ into some number of non-empty contiguous subsequence $B_1, B_2, \\ldots, B_k$ so that the following condition is satisfie",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc207_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given is a sequence $A$ of $N$ numbers. Find the number of ways to separate $A$ into some number of non-empty contiguous subsequence $B_1, B_2, \\ldots, B_k$ so that the following condition is satisfie...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments