#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void printV(vector<T>& a) {
  for (int i = 0; i < ((int)((a).size())); i++) {
    cout << a[i] << " ";
  }
  cout << "\n";
}
template <typename T>
inline void printV(vector<T>& a, int n) {
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << "\n";
}
template <typename T>
inline void printVV(vector<vector<T>>& a) {
  for (int i = 0; i < ((int)((a).size())); i++) {
    printV(a[i]);
  }
  cout << "\n";
}
template <typename T>
inline void clearVV(vector<vector<T>>& a) {
  for (auto& x : a) {
    x.clear();
  }
  a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>>& a, T val) {
  for (int i = 0; i < ((int)((a).size())); i++) {
    for (int j = 0; j < ((int)((a[i]).size())); j++) {
      a[i][j] = val;
    }
  }
}
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9 + 7;
const int MAX = 1e5;
inline int add(int a, int b) { return ((long long)a + b) % modn; }
inline int mul(int a, int b) { return ((long long)a * b) % modn; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  vector<vector<int>> psum(n + 1, vector<int>(k + 1));
  vector<vector<int>> dp(n + 1, vector<int>(k + 1));
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int j = 0; j <= k; j++) {
    dp[1][j] = (j <= a[1] ? 1 : 0);
    if (j > 0)
      psum[1][j] = add(psum[1][j - 1], dp[1][j]);
    else
      psum[1][j] = dp[1][j];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      if (j > a[i]) {
        dp[i][j] = psum[i - 1][j] - psum[i - 1][j - a[i] - 1];
        psum[i][j] = add(psum[i][j - 1], dp[i][j]);
        continue;
      }
      dp[i][j] = psum[i - 1][j];
      if (j > 0)
        psum[i][j] = add(psum[i][j - 1], dp[i][j]);
      else
        psum[i][j] = dp[i][j];
    }
  }
  cout << dp[n][k] << "\n";
  return 0;
}
