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