#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long dp[n][k + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i <= a[n - 1]; i++) dp[n - 1][i] = 1;
  for (int i = 0; i < n; i++) dp[i][0] = 1;
  for (int i = n - 2; i >= 0; i--) {
    for (int j = 1; j <= a[i]; j++)
      dp[i][j] = (dp[i][j - 1] + dp[i + 1][j]) % 1000000007;
    for (int j = a[i] + 1; j <= k; j++)
      dp[i][j] = ((dp[i][j - 1] + dp[i + 1][j]) % 1000000007 -
                  dp[i + 1][j - a[i] + 1] % 1000000007 + 1000000007) %
                 1000000007;
  }
  cout << dp[0][k] % 1000000007 << "\n";
  return 0;
}
