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