#include <bits/stdc++.h>
using namespace std;
long long int solve(long long int n, long long int k,
                    vector<long long int> &v) {
  long long int dp[n + 1][k + 1];
  for (long long int i = 0; i <= k; i++) {
    dp[1][i] = (i <= v.at(1) ? (1) : (0));
  }
  for (long long int i = 2; i <= n; i++) {
    for (long long int j = 0; j <= k; j++) {
      if (j == 0) {
        dp[i][j] = dp[i - 1][j];
      } else {
        dp[i][j] = ((dp[i][j - 1]) % 1000000007 + (dp[i - 1][j]) % 1000000007 -
                    ((j - 1 - v[i] >= 0) ? (dp[i - 1][j - 1 - v[i]]) : 0) %
                        1000000007) %
                   1000000007;
      }
    }
  }
  return dp[n][k];
}
int main() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> v(n + 1);
  for (long long int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  cout << solve(n, k, v);
  return 0;
}
