using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("4");
WillReturn.Add("1 2 3 4");
//3
}
else if (InputPattern == "Input2") {
WillReturn.Add("5");
WillReturn.Add("8 6 3 3 3");
//5
}
else if (InputPattern == "Input3") {
WillReturn.Add("10");
WillReturn.Add("791754273866483 706434917156797 714489398264550 918142301070506 559125109706263 694445720452148 648739025948445 869006293795825 718343486637033 934236559762733");
//15
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
const long AnswerHou = 1000000007;
static long[] mAArr;
static long UB;
static long[] mRunSumArr;
static void Main()
{
List<string> InputList = GetInputList();
mAArr = InputList[1].Split(' ').Select(pX => long.Parse(pX)).ToArray();
// 最後に番兵0を追加
var AList = new List<long>();
AList.AddRange(mAArr);
AList.Add(0);
mAArr = AList.ToArray();
UB = mAArr.GetUpperBound(0);
// 累積和を求める
mRunSumArr = (long[])mAArr.Clone();
for (long I = 1; I <= UB; I++) {
mRunSumArr[I] += mRunSumArr[I - 1];
}
Solve();
}
static void Solve()
{
long UB_Ind = UB;
long UB_Hou = mAArr.Length;
// 場合の数[現在の添え字 , 次の数列の法] なDP表
long[,] DPArr = new long[UB_Ind + 1, UB_Hou + 1];
DPArr[0, 1] = 1;
// 配った数[法,mod]
long[,] SendArr = new long[UB_Hou + 1, UB_Hou];
for (long I = 0; I <= UB_Ind; I++) {
for (long J = UB_Hou; 1 <= J; J--) {
long PrevRunSum = mRunSumArr[I] - mAArr[I];
long PrevHou = J - 1;
long GetVal = 0;
if (PrevHou > 0) {
GetVal += SendArr[PrevHou, PrevRunSum % PrevHou];
GetVal %= AnswerHou;
}
DPArr[I, J] += GetVal;
DPArr[I, J] %= AnswerHou;
SendArr[J, PrevRunSum % J] += DPArr[I, J];
SendArr[J, PrevRunSum % J] %= AnswerHou;
}
}
long Answer = 0;
for (long I = 0; I <= UB_Hou; I++) {
Answer += DPArr[UB_Ind, I];
Answer %= AnswerHou;
}
Console.WriteLine(Answer);
}
}