#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e5 + 5;
long long MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long a[n + 2];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long dp[n + 2][k + 2], pre[n + 2][k + 2];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      pre[i][j] = 0;
    }
  }
  for (int i = 0; i <= k; i++) {
    dp[0][i] = 0;
  }
  for (int i = 0; i <= n; i++) {
    dp[i][0] = 1;
    pre[i][0] = 1;
  }
  pre[0][0] = 1;
  for (int i = 1; i <= k; i++) {
    pre[0][i] += pre[0][i - 1];
  }
  for (int i = 1; i <= n; i++) {
    long long x = a[i];
    for (int j = 1; j <= k; j++) {
      if (j <= x) {
        dp[i][j] = pre[i - 1][j];
      } else {
        long long prev = j - a[i];
        dp[i][j] = pre[i - 1][j] - pre[i - 1][prev - 1];
      }
      pre[i][j] = (pre[i][j - 1] + dp[i][j]) % MOD;
    }
  }
  cout << dp[n][k] % MOD << endl;
  return 0;
}
