#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
const long long p = 998244353;
vector<long long int> visited;
vector<long long int> group;
vector<vector<long long int> > adj;
void dfs(long long int s, long long int count) {
  if (visited[s]) return;
  visited[s] = 1;
  group[s] = count;
  for (long long int i = 0; i < (long long int)(adj[s].size()) - 1; i++) {
    if (!visited[adj[s][i]]) dfs(adj[s][i], count);
  }
}
signed main() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n + 1];
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  long long int dp[n + 1][k + 1];
  long long int pref[n + 1][k + 1];
  for (long long int i = 0; i <= n; i++) {
    for (long long int j = 0; j <= k; j++) {
      pref[i][j] = 0;
      dp[i][j] = 0;
    }
  }
  for (long long int i = 0; i <= n; i++) dp[i][0] = 1;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= k; j++) {
      pref[i - 1][j] = pref[i - 1][j - 1] + dp[i - 1][j];
      pref[i - 1][j] = pref[i - 1][j] % MOD;
      if (j <= a[i])
        dp[i][j] = pref[i - 1][j];
      else
        dp[i][j] = pref[i - 1][j] - pref[i - 1][j - a[i]];
      if (dp[i][j] < 0) dp[i][j] += MOD;
      dp[i][j] %= MOD;
    }
  }
  cout << dp[n][k] << '\n';
}
