#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  for (auto i = 1; i <= n; ++i) cin >> a[i];
  int dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  for (auto i = 0; i <= a[1]; ++i) {
    dp[1][i] = 1;
  }
  for (auto i = 2; i <= n; ++i) {
    dp[i][0] = 1;
    for (auto j = 1; j <= a[i]; j++) {
      dp[i][j] = (dp[i][j - 1] % M + dp[i - 1][j] % M) % M;
    }
    for (auto j = a[i] + 1; j <= k; j++) {
      dp[i][j] =
          (dp[i][j - 1] % M + dp[i - 1][j] % M - dp[i - 1][j - a[i] - 1] % M) %
          M;
    }
  }
  cout << dp[n][k];
  return 0;
}
