#include <bits/stdc++.h>
using namespace std;
long long int n, k;
long long int a[100002];
long long int solve() {
  vector<vector<long long int> > dp(n + 1, vector<long long int>(k + 2));
  for (long long int j = 0; j <= k; j++) dp[1][j] = ((j > a[1]) ? 0 : 1);
  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 {
        long long int x = (((j - a[i]) >= 0) ? dp[i - 1][j - a[i] - 1] : 0);
        dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - x + 1000000007) % 1000000007;
      }
    }
  }
  return dp[n][k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  };
  cout << solve() << endl;
  return 0;
}
