#include <bits/stdc++.h>
using namespace std;
long long mod(long long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0) return c;
  return c + (long long)(1E9 + 7);
}
long long inf = (long long)1E16;
long long max(long long a, long long b) {
  if (a < b)
    return b;
  else
    return a;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
void Max(long long &pos, long long val) { pos = max(pos, val); }
void Min(long long &pos, long long val) { pos = min(pos, val); }
void Add(long long &pos, long long val) { pos = mod(pos + val); }
long double EPS = 1E-9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i <= n - 1; i++) cin >> a[i];
  long long dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  for (long long i = 0; i <= k; i++) dp[0][i] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j - 1 - a[i - 1] >= 0) Add(dp[i][j], -dp[i - 1][j - a[i - 1] - 1]);
    }
    for (long long j = 1; j <= k; j++) Add(dp[i][j], dp[i][j - 1]);
  }
  cout << mod(dp[n][k] - dp[n][k - 1]) << "\n";
  return 0;
}
