#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, j;
  cin >> n >> k;
  int a[n];
  for (i = 1; i <= n; i++) cin >> a[i];
  long long dp[n + 2][k + 2];
  for (j = 0; j <= k; j++) {
    dp[1][j] = (j > a[1]) ? 0 : 1;
  }
  for (i = 2; i <= n; i++) {
    for (j = 0; j <= k; j++) {
      if (j == 0)
        dp[i][j] = dp[i - 1][j];
      else {
        if (j - a[i] - 1 >= 0)
          dp[i][j] = (dp[i][j - 1] % 1000000007 + dp[i - 1][j] % 1000000007 -
                      dp[i - 1][j - 1 - a[i]] % 1000000007) %
                     1000000007;
        else
          dp[i][j] = (dp[i][j - 1] % 1000000007 + dp[i - 1][j] % 1000000007) %
                     1000000007;
      }
    }
  }
  cout << dp[n][k] % 1000000007 << "\n";
  return 0;
}
