#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long dp[n][k + 1];
  for (int j = 0; j <= k; j++) {
    if (j <= a[0])
      dp[0][j] = 1;
    else
      dp[0][j] = 0;
  }
  for (int i = 1; i < n; i++) {
    long long pre[k + 1];
    for (int j = 0; j <= k; j++) {
      pre[j] = dp[i - 1][j];
      if (j > 0) pre[j] = (pre[j] + pre[j - 1]) % mod;
    }
    for (int j = 0; j <= k; j++) {
      int st = j - min(a[i], j);
      int end = j;
      long long x = 0;
      if (st > 0) x = pre[st - 1];
      dp[i][j] = pre[end] - x;
    }
  }
  cout << dp[n - 1][k];
}
