#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > dp;
long long game(vector<long long> a, int n, int candies) {
  if (candies < 0) return 0;
  if (candies == 0) return 1;
  if (n == 1) {
    if (candies > a[n - 1])
      return 0;
    else
      return 1;
  }
  if (dp[n][candies] != -1) return dp[n][candies];
  long long ans = 0;
  for (int i = 0; i <= a[n - 1]; i++) {
    ans += game(a, n - 1, candies - i) % 1000000007;
    ans %= 1000000007;
  }
  dp[n][candies] = ans;
  return ans;
}
int main() {
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < (n); ++i) {
      cin >> a[i];
    }
    dp.clear();
    dp.resize(n + 1, vector<long long>(k + 1));
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= k; j++) {
        if (j == 0) {
          dp[i][j] = 1;
          continue;
        }
        if (i == 1) {
          if (j > a[i - 1])
            dp[i][j] = 0;
          else
            dp[i][j] = 1;
          continue;
        }
        dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
        if (j - a[i - 1] > 0) dp[i][j] -= dp[i - 1][j - a[i - 1] - 1];
        dp[i][j] %= 1000000007;
      }
    }
    cout << dp[n][k];
  }
  return 0;
}
