#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
int Candies(vector<int> &candy, int n, int k) {
  vector<vector<int> > DP(n + 1, vector<int>(k + 1, 0));
  DP[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    long long sum = 0;
    for (int j = 0; j <= k; j++) {
      sum += DP[i - 1][j];
      sum %= MOD;
      if (j > candy[i]) {
        sum -= DP[i - 1][j - candy[i] - 1];
        sum %= MOD;
      }
      DP[i][j] = sum;
    }
  }
  return DP[n][k];
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> candy(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> candy[i];
  }
  int ans = Candies(candy, n, k);
  cout << ans << endl;
}
