#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ifstream myFile("task.in");
  if (!myFile.fail()) {
    assert(freopen("task.in", "r", stdin));
  }
  long long int n, k;
  cin >> n >> k;
  long long int arr[n + 1];
  for (long long int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  vector<vector<long long int> > dp(n + 1, vector<long long int>(k + 1, 0));
  for (long long int i = 0; i <= n; i++) {
    dp[i][0] = 1;
  }
  for (long long int j = 0; j <= k; j++) {
    dp[0][j] = 1;
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= k; j++) {
      long long int x = max(j - arr[i], (long long int)0);
      if (x == 0) {
        dp[i][j] = (dp[i][j - 1] % 1000000007 + dp[i - 1][j] % 1000000007) %
                   1000000007;
      } else {
        long long int y = (dp[i - 1][j] % 1000000007 -
                           dp[i - 1][x - 1] % 1000000007 + 1000000007) %
                          1000000007;
        dp[i][j] = (dp[i][j - 1] % 1000000007 + y % 1000000007) % 1000000007;
      }
    }
  }
  long long int y =
      (dp[n][k] % 1000000007 - dp[n][k - 1] % 1000000007 + 1000000007) %
      1000000007;
  cout << y << endl;
  return 0;
}
