#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 10;
inline long long add(long long x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline long long mul(long long x, long long y) {
  x = (1LL * x * y) % mod;
  return x;
}
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  for (long long i = 1; i <= n; ++i) cin >> a[i];
  long long dp[n + 1][k + 1];
  long long sum[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  memset(sum, 0, sizeof(sum));
  for (long long i = 0; i <= k; ++i)
    if (i <= a[1])
      dp[1][i] = 1;
    else
      dp[1][i] = 0;
  sum[1][0] = 1;
  for (long long i = 1; i <= k; ++i) sum[1][i] = add(sum[1][i - 1], dp[1][i]);
  for (long long i = 1; i <= n; ++i) dp[i][0] = 1;
  for (long long i = 2; i <= n; ++i) {
    sum[i][0] = 1;
    for (long long j = 1; j <= k; ++j) {
      if (a[i] < j) {
        dp[i][j] = sum[i - 1][j] - sum[i - 1][j - a[i] - 1];
      } else
        dp[i][j] = sum[i - 1][j];
      sum[i][j] = add(sum[i][j - 1], dp[i][j]);
    }
  }
  cout << dp[n][k];
  return 0;
}
