#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<long long, long long> &a,
          const pair<long long, long long> &b) {
  return a.second < b.second;
}
long long func(long long a[], long long n, long long k) {
  if (k == 0) return 1;
  if (k < 0 || n == 0) return 0;
  long long ans = 0;
  for (long long i = 0; i < a[n - 1] + 1; i++) {
    ans += func(a, n - 1, k - i);
    ans %= 1000000007;
  }
  return ans;
}
int main() {
  long long n, k, l, r;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long dp[n + 1][k + 1], p[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  memset(p, 0, sizeof(p));
  for (long long i = 0; i < n + 1; i++) {
    dp[i][0] = 1;
    p[i][0] = 1;
  }
  for (long long j = 1; j < k + 1; j++) p[0][j] += p[0][j - 1];
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < k + 1; j++) {
      r = j;
      l = j - a[i - 1];
      dp[i][j] += p[i - 1][r];
      dp[i][j] %= 1000000007;
      if (l > 0) dp[i][j] -= p[i - 1][l - 1];
      p[i][j] = p[i][j - 1] + dp[i][j];
      p[i][j] %= 1000000007;
    }
  }
  cout << dp[n][k];
}
