#include <bits/stdc++.h>
using namespace std;
int mod = 1e9;
vector<vector<int>> dp;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  for (int &i : A) cin >> i;
  dp.resize(n + 1, vector<int>(k + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= k; i++) dp[0][i] = 1;
  for (int i = 1; i <= n; i++) dp[i][0] += dp[i - 1][0];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      if (j > A[i - 1])
        dp[i][j] = dp[i - 1][j] - dp[i - 1][j - A[i - 1] - 1];
      else {
        dp[i][j] = dp[i - 1][j];
      }
      dp[i][j] = (dp[i][j] + dp[i][j - 1]) % (mod + 7);
    }
  }
  cout << dp[n][k] - dp[n][k - 1];
}
