#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1e9 + 7;
long long int min(long long int a, long long int b) { return (a < b) ? a : b; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int a[n + 1];
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  a[0] = 0;
  long long int dp[n + 1][k + 1];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= k; j++) dp[i][j] = 0;
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = dp[i - 1][0];
    for (int j = 1; j <= k; j++) {
      if (j <= a[i])
        dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % MOD;
      else
        dp[i][j] = (dp[i][a[i]] - dp[i][j - a[i] - 1]) % MOD;
    }
  }
  cout << dp[n][k];
}
