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