#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int go(long long int choco[], long long int n, long long int k) {
  long long int dp[n + 1][100005];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      if (i == 0) dp[i][j] = 0;
      if (j == 0) dp[i][j] = 1;
    }
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    vector<int> prefix(k + 1);
    prefix[0] = dp[i - 1][0];
    for (int j = 1; j <= k; j++)
      prefix[j] = (dp[i - 1][j] % mod + prefix[j - 1] % mod) % mod;
    for (int j = 1; j <= k; j++) {
      long long int x = choco[i];
      if (j <= x)
        dp[i][j] = prefix[j] % mod;
      else
        dp[i][j] = prefix[j] % mod - prefix[j - x - 1] % mod;
    }
  }
  return dp[n][k] % mod;
}
int main() {
  int n, k;
  cin >> n >> k;
  long long int choco[n + 1];
  for (int i = 1; i <= n; i++) cin >> choco[i];
  cout << go(choco, n, k) << endl;
  return 0;
}
