#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int a[n], s[n], dp[n][k + 1];
  for (int i = 0; i < n; i++) cin >> a[i];
  s[0] = 1;
  dp[0][0] = 1;
  for (int j = 1; j <= k; j++) {
    if (j <= a[0])
      dp[0][j] = 1;
    else
      dp[0][j] = 0;
    s[j] = s[j - 1] + dp[0][j];
  }
  for (int i = 1; i < n; i++) {
    dp[i][0] = 1;
    for (int j = 1; j <= k; j++) {
      if (j <= a[i])
        dp[i][j] = s[j];
      else
        dp[i][j] = s[j] - s[j - a[i] - 1];
    }
    for (int j = 1; j <= k; j++) {
      s[j] = (s[j - 1] + dp[i][j]) % 1000000007;
    }
  }
  cout << dp[n - 1][k] << "\n";
}
