#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<long long int> cost;
  for (int i = 0; i < n; i++) {
    long long int a;
    cin >> a;
    cost.push_back(a);
  }
  vector<vector<long long int> > dp;
  for (int i = 0; i < n; i++) {
    vector<long long int> r;
    for (int j = 0; j < k + 1; j++) {
      r.push_back(0);
    }
    dp.push_back(r);
  }
  for (int i = 0; i < n; i++) {
    dp[i][0] = 1;
  }
  for (int i = 0; i <= k; i++) {
    if (i <= cost[0]) dp[0][i] = 1;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < k + 1; j++) {
      if (j <= cost[i])
        dp[i][j] = (dp[i - 1][j] % 1000000007 + dp[i][j - 1] % 1000000007) %
                   1000000007;
      else
        dp[i][j] = (dp[i - 1][j] % 1000000007 + dp[i][j - 1] % 1000000007 -
                    dp[i - 1][j - cost[i] - 1] % 1000000007) %
                   1000000007;
    }
  }
  cout << dp[n - 1][k];
}
