#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
void printDP(vector<vector<long long int> > dp) {
  for (int i = 0; i < dp.size(); i++) {
    for (int j = 0; j < dp[i].size(); j++) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
}
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> v(n + 1);
  for (int i = 1; i <= n; i++) cin >> v[i];
  vector<vector<long long int> > dp(n + 1, vector<long long int>(m + 1));
  for (int i = 0; i <= m; i++) dp[0][i] = 1;
  for (int i = 0; i <= n; i++) dp[i][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      dp[i][j] += dp[i][j - 1];
      if (dp[i][j] >= mod) dp[i][j] -= mod;
      if (j - v[i] <= 0)
        dp[i][j] += dp[i - 1][j];
      else
        dp[i][j] += dp[i - 1][j] - dp[i - 1][j - v[i] - 1];
      if (dp[i][j] >= mod) dp[i][j] -= mod;
    }
  }
  cout << ((dp[n][m] - (m - 1 >= 0 ? dp[n][m - 1] : 0)) + mod) % mod << endl;
}
