#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int INF = LONG_LONG_MAX;
inline long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
inline long long int pow(long long int a, long long int n, long long int mod) {
  if (n == 0) return 1;
  long long int p = pow(a, n / 2, mod);
  p = (p % mod * p % mod) % mod;
  if (n % 2)
    return (p % mod * a % mod) % mod;
  else
    return p;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int dp[n + 1][k + 1];
  long long int pre[n + 1][k + 1];
  for (long long int i = 0; i <= n; i++) {
    for (long long int j = 0; j <= k; j++) {
      dp[i][j] = 0;
      if (j == 0) {
        dp[i][j] = 1;
        pre[i][j] = dp[i][j];
        continue;
      }
      if (i == 0) {
        dp[i][j] = 0;
        pre[i][j] = 1;
        continue;
      }
      long long int d = min(a[i - 1], a[i - 1]);
      dp[i][j] = (pre[i - 1][j] % mod -
                  ((j - d - 1) >= 0 ? pre[i - 1][j - d - 1] : 0) % mod) %
                 mod;
      pre[i][j] = (pre[i][j - 1] % mod + dp[i][j] % mod) % mod;
    }
  }
  cout << dp[n][k] % mod << "\n";
  return 0;
}
