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