#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
const int MOD = 1e9 + 7;
int a[MAX], dp[MAX][2];
int addMod(int a, int b) { return ((a + b) % MOD + MOD) % MOD; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int r = 0; r <= a[0]; ++r) {
    dp[r][0] = 1;
  }
  int prefix = 0;
  for (int c = 1, old_c, i = 1; i < n; ++i, c = !c) {
    prefix = dp[0][c] = 1;
    old_c = !c;
    for (int r = 1; r <= a[c]; ++r) {
      prefix = addMod(prefix, dp[r][old_c]);
      dp[r][c] = prefix;
    }
    for (int r = a[c] + 1; r <= k; ++r) {
      prefix = addMod(prefix, dp[r][old_c] - dp[r - a[i] - 1][old_c]);
      dp[r][c] = prefix;
    }
  }
  cout << dp[k][!(n & 1)] << '\n';
  return 0;
}
