#include <bits/stdc++.h>
using namespace std;
long long int inf = 1e14;
long long int mod = 1e9 + 7;
char en = '\n';
long long int abs1(long long int x) {
  if (x < 0) return -x;
  return x;
}
long long int power(long long int x, long long int n, long long int mod) {
  long long int res = 1;
  while (n) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
long long int dp[1005][100005];
long long int pre[1005][100005];
long long int arr[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  for (long long int i = 1; i <= n; i++) cin >> arr[i];
  memset(dp, 0, sizeof(dp));
  memset(pre, 0, sizeof(pre));
  dp[0][0] = 1;
  pre[0][0] = 1;
  for (long long int i = 1; i <= k; i++)
    pre[0][i] = (pre[0][i - 1] + dp[0][i]) % mod;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 0; j <= k; j++) {
      long long int st = max(j - arr[i], 0ll);
      long long int end1 = j;
      if (st)
        dp[i][j] = (pre[i - 1][end1] - pre[i - 1][st - 1] + mod) % mod;
      else
        dp[i][j] = pre[i - 1][end1];
      if (j) pre[i][j] = pre[i][j - 1];
      pre[i][j] = (pre[i][j] + dp[i][j]) % mod;
    }
  }
  cout << dp[n][k] << en;
  return 0;
}
