#include <bits/stdc++.h>
using namespace std;
int mod = 1e9;
vector<vector<int>> dp;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  for (int &i : A) cin >> i;
  dp.resize(n + 1, vector<int>(k + 1, 1));
  vector<vector<int>> p = dp;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      if (j > A[i - 1])
        dp[i][j] = p[i - 1][j] - p[i - 1][j - A[i - 1] - 1];
      else {
        dp[i][j] = p[i - 1][j];
      }
      p[i][j] = (dp[i][j] + p[i][j - 1]) % (mod + 7);
    }
  }
  cout << dp[n][k];
}
