import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

i番目までの子供にj個の飴を分ける分け方の数 xs[i][j]

j <= a[i] のとき
 xs[i][j] = sum(u; 0 ..= j) xs[i - 1][u]

j > a[i] のとき
 xs[i][j] = sum(u; j - a[i] ..= j) xs[i - 1][u]


これをそのまま実装するとTLEになるので、以下のように実装する

j = 0 のとき
 xs[i][j] = 1

j <= a[i] のとき
 xs[i][j] = xs[i][j - 1] + xs[i - 1][j]

j > a[i] のとき
 xs[i][j] = xs[i][j - 1] + xs[i - 1][j] - xs[i - 1, j - a[i] - 1]	


*/

const long mod = 1_000_000_007;

void main(){
 int n = read.to!int;
 int k = read.to!int;
	
 int[] as = readln.chomp.split.map!(to!int).array;
	
 long[][] xs = [[]];
 foreach(j; 0 .. k + 1){
  if(j <= as[0]) xs[0] ~= 1;
  else xs[0] ~= 0;
 }
 debug writeln("i:0 xs:", xs);
	
 foreach(i; 1 .. n){
  xs ~= [[]];
  foreach(j; 0 .. k + 1){
   if(j == 0) xs[i] ~= 1;
   else if(j <= as[i]) xs[i] ~= xs[i][j - 1] + xs[i - 1][j];
   else xs[i] ~= xs[i][j - 1] + xs[i - 1][j] + mod - xs[i - 1][j - as[i] - 1];
   xs[i][j] %= mod;
  }
  debug writeln("i:", i, " xs:", xs);
 }
	
 xs[n - 1][k].writeln;
}