#include <bits/stdc++.h>
#pragma GCC optimize "trapv"
using namespace std;
int MOD = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++) cin >> a[i];
    long long dp[n + 1][k + 1];
    long long pre[n + 1][k + 1];
    for (int i = 0; i <= n; i++)
      for (int j = 0; j <= k; j++) dp[i][j] = 0;
    for (int i = 0; i <= a[1]; i++) dp[1][i] = 1;
    pre[1][0] = dp[1][0];
    for (int i = 1; i <= k; i++) pre[1][i] = (pre[1][i - 1] + dp[1][i]) % MOD;
    for (int i = 2; i <= n; i++) {
      for (int j = 0; j <= k; j++) {
        int x = max(j - a[i], 0);
        if (x > 0)
          dp[i][j] = pre[i - 1][j] - pre[i - 1][x - 1];
        else
          dp[i][j] = pre[i - 1][j];
      }
      pre[i][0] = dp[i][0];
      for (int j = 1; j <= k; j++) pre[i][j] = (pre[i][j - 1] + dp[i][j]) % MOD;
    }
    cout << dp[n][k];
  }
}
