#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll M = 1e9+7;


int main() {
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  ll dp[n+1][k+1]={0};
  dp[0][0] = 1;
  for(int j=0;j<=a[0];j++) dp[1][j] = 1;
  ll sum[k+1];
  for(int i=2;i<=n;i++) {
    sum[0] = dp[i-1][0];
	for(int j=1;j<=k;j++) sum[j]=(dp[i-1][j]+sum[j-1])%M;
  	for(int j=0;j<=k;j++) {
      if(j<=a[i-1]) dp[i][j] = sum[j];
      else {
          int p = j-a[i-1];
          dp[i][j] = sum[j]-sum[p-1];
      }
    }
  }
  
  cout<<dp[n][k]%M<<endl;
}