using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.DP
{
    class EDPC_M
    {
        public static void Main()
        {
            var nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var n = nk[0];
            var k = nk[1];

            const long mod = 1000000007;
             
            var dp = new long[n + 1, k + 1];

            var acc = a.Clone() as int[];
            for (int i = 1; i < n; i++)
                acc[i] += acc[i - 1];

            for (int i = 1; i <= n; i++)
            {
                dp[i, 0] = 1;
                for (int j = 1; j <= Math.Min(acc[i - 1], k); j++)
                {
                    dp[i, j] = dp[i - 1, j] + dp[i, j - 1];
                    if (j - 1 >= a[i - 1])
                        dp[i, j] -= dp[i - 1, j - 1 - a[i - 1]];
                    dp[i, j] %= mod;
                }
            }
            Console.WriteLine(dp[n, k]);
        }
    }
}
