#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k, ans = 0;
  cin >> n >> k;
  vector<long long int> vec(n + 1);
  long long int dp[n + 2][k + 2], pre[n + 2][k + 2];
  for (int i = 1; n >= i; i++) {
    cin >> vec[i];
  }
  for (int i = 0; n >= i; i++) {
    dp[i][0] = pre[i][0] = 1;
  }
  for (int i = 0; k >= i; i++) {
    pre[0][i] = 1;
  }
  for (int i = 1; n >= i; i++) {
    for (int j = 1; k >= j; j++) {
      dp[i][j] = pre[i - 1][j];
      if (j - 1 >= vec[i]) {
        dp[i][j] -= pre[i - 1][j - 1 - vec[i]];
      }
      pre[i][j] = pre[i][j - 1] + dp[i][j];
      pre[i][j] += 1000000007;
      pre[i][j] %= 1000000007;
    }
  }
  cout << dp[n][k];
}
