using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static long mod = 1000000007;

		static int N;
		static int K;
		static int[] a;

		static long[,,] dp;

		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			N = vs[0];
			K = vs[1];
			a = Console.ReadLine().Split().Select(int.Parse).ToArray();

			dp = new long[N, K + 1, 2];
			for (int i = 0; i <= a[0]; i++) {
				dp[0, i, 0] = 1;
				dp[0, i, 1] = i + 1;
			}

			int sum = a[0];
			for (int i = 1; i < N; i++) {
				sum += a[i];
				dp[i, 0, 0] = 1;
				dp[i, 0, 1] = 1;
				for (int j = 1; j <= K; j++) {
					if (j > sum) {
						break;
					}
					dp[i, j, 0] = dp[i - 1, j, 0] + dp[i, j - 1, 0];
					dp[i, j, 1] = dp[i, j - 1, 0] + dp[i, j, 0];
					if (j > a[i]) {
						dp[i, j, 0] -= dp[i, j - a[i] - 1, 1];
					}
					dp[i, j, 0] = dp[i, j, 0] % mod;
					dp[i, j, 1] = dp[i, j, 1] % mod;
				}
			}
			Console.WriteLine(dp[N - 1, K, 0]);
		}
	}
}
