#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int add(int x, int y) {
  x += y;
  if (x >= MOD) return x - MOD;
  return x;
}
int sub(int x, int y) {
  x -= y;
  if (x < 0) return x + MOD;
  return x;
}
int main(int argc, char* argv[]) {
  int N, K;
  cin >> N >> K;
  vector<int> a(N + 1, 0);
  vector<vector<pair<int, int>>> dp(
      N + 1, vector<pair<int, int>>(K + 1, make_pair(0, 0)));
  for (int i = 1; i <= N; ++i) cin >> a[i];
  dp[0][0].first = 1;
  dp[0][0].second = 1;
  for (int i = 1; i <= N; ++i) {
    for (int j = K; j >= 0; --j) {
      int left = a[i] > j ? 0 : j - a[i];
      if (dp[i - 1][left].first) {
        if (j) {
          dp[i][j].first = add(dp[i][j].first, dp[i - 1][left].second);
          int right = a[i] - j;
          if (right > 0) {
            dp[i][j].first =
                sub(dp[i][j].first, dp[i - 1][K - right + 1].second);
          }
        } else
          dp[i][j].first = 1;
        dp[i][j].second = add(dp[i][j].first, dp[i][j + 1].second);
      } else {
        dp[i][j].first = 0;
        dp[i][j].second = dp[i][j + 1].second;
      }
    }
  }
  cout << dp[N][K].first % MOD;
}
