#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;

long int main()
{
  ios::sync_with_stdio(false);

  long int N,K;
  cin>>N>>K;
  vector<vector<int>>dp(N+1,vector<int>(K+1,-1));
  vector<int>a(N+1);
  for(long int i=0;i<N;i++)
  {
    cin>>a[i+1];
  }
  for(long int i=0;i<K+1;i++)
  {
    if(a[1]>=i)dp[1][i]=i+1;
    else  dp[1][i]=a[1]+1;
  }
  for(long int i=2;i<N+1;i++)
  {
    dp[i][0]=1;
    for(long int j=1;j<K+1;j++)
    {
      if(j>a[i])dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-a[i]-1];
      else dp[i][j]=dp[i][j-1]+dp[i-1][j];
      dp[i][j]%=1000000007;
    }
  }
  if(dp[N][K]<0){dp[N][K]+=1000000007;dp[N][K]%=1000000007;}
  long int res=dp[N][K]-dp[N][K-1];
  if(res<0){res+=1000000007;res%=1000000007;}
  if(K>0){cout<<res;return 0;}
  cout<<dp[N][K];
  cout<<endl;

}
