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