#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\t";
  err(++it, args...);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& c, pair<T1, T2>& v) {
  c << "(" << v.first << "," << v.second << ")";
  return c;
}
template <template <class...> class TT, class... T>
ostream& operator<<(ostream& out, TT<T...>& c) {
  out << "{ ";
  for (auto& x : c) out << x << " ";
  out << "}";
  return out;
}
const long long int MOD = 1e9 + 7, LIM = 1e5 + 5;
const long double EPS = 1e-9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  long long int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long int dp[n][k + 1];
  long long int add[n][k + 1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k + 1; j++) {
      dp[i][j] = 0;
      add[i][j] = 0;
    }
  }
  for (int j = 0; j < a[0]; j++) {
    dp[0][j] = 1;
    add[0][j] = j + 1;
  }
  for (int j = a[0]; j < k + 1; j++) add[0][j] = a[0] + 1;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < k + 1; j++) {
      if (a[i] >= j)
        dp[i][j] = add[i - 1][j];
      else
        dp[i][j] =
            (MOD + add[i - 1][j] - add[i - 1][max(0LL, j - 1 - a[i])]) % MOD;
    }
    for (int j = 0; j < k + 1; j++) {
      if (j == 0)
        add[i][j] = dp[i][j];
      else
        add[i][j] = (add[i][j - 1] + dp[i][j]) % MOD;
    }
  }
  cout << dp[n - 1][k] << endl;
  return 0;
}
