#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    long long tmpsum = 0;
    for (int j = 0; j <= k; j++) {
      tmpsum += dp[i - 1][j] % long long(1e9 + 7);
      if (j - a[i - 1] - 1 >= 0) {
        tmpsum += long long(1e9 + 7);
        tmpsum -= dp[i - 1][j - a[i - 1] - 1];
        tmpsum %= long long(1e9 + 7);
      }
      dp[i][j] = tmpsum;
    }
  }
  cout << dp[n][k] % long long(1e9 + 7) << endl;
  return 0;
}
