#include <bits/stdc++.h>
using namespace std;
long long int fast(long long int n, long long int a, long long int m) {
  if (n == 0)
    return 1;
  else if (n == 1)
    return a;
  else {
    long long int r = fast(n / 2, a, m);
    if (n % 2 == 0) {
      return (((r % m) * (r % m)) % m);
    } else {
      return (((((r % m) * a) % m) * r) % m);
    }
  }
}
int main() {
  long long int n, K;
  cin >> n >> K;
  long long int a[n];
  long long int i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int dp[n + 1][K + 1], pref[n + 1][K + 1];
  memset(pref, 0, sizeof(pref));
  memset(dp, 0, sizeof(dp));
  for (i = 0; i <= a[0]; i++) {
    dp[1][i] = 1;
  }
  pref[1][0] = dp[1][0];
  for (i = 1; i <= K; i++) {
    pref[1][i] =
        (pref[1][i - 1] % 1000000007 + dp[1][i] % 1000000007) % 1000000007;
  }
  for (i = 2; i <= n; i++) {
    dp[i][0] = dp[i - 1][0] % 1000000007;
    for (j = 1; j <= K; j++) {
      long long int u = j - a[i - 1];
      if (u <= 0)
        dp[i][j] = pref[i - 1][j];
      else
        dp[i][j] = pref[i - 1][j] - pref[i - 1][u - 1];
      if (dp[i][j] < 0) {
        dp[i][j] += 1000000007;
        dp[i][j] %= 1000000007;
      }
    }
    pref[i][0] = dp[i][0] % 1000000007;
    for (j = 1; j <= K; j++)
      pref[i][j] =
          (pref[i][j - 1] % 1000000007 + dp[i][j] % 1000000007) % 1000000007;
  }
  cout << dp[n][K];
}
