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