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