#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void join(const vector<string>& v, char c, string& s) {
  s.clear();
  for (vector<string>::const_iterator p = v.begin(); p != v.end(); ++p) {
    s += *p;
    if (p != v.end() - 1) s += c;
  }
}
long long solve(vector<long long> arr, long long n, long long k) {
  long long dp[n + 1][k + 1];
  long long dp1[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1LL;
  dp1[0][0] = 1LL;
  for (long long i = 0; i < arr.size(); i++) {
    long long ps[k + 1];
    memset(ps, 0, sizeof(ps));
    for (long long j = 0; j < k + 1; j++) {
      ps[j] = (dp[i][j] + (j - 1 >= 0 ? ps[j - 1] : 0)) % (long long)1000000007;
    }
    for (long long j = 0; j < k + 1; j++) {
      const auto maxToTakeWithThisJAndThisArr =
          ((arr[i]) < (j) ? (arr[i]) : (j));
      dp[i + 1][j] = (ps[j] - (j - maxToTakeWithThisJAndThisArr - 1 >= 0
                                   ? ps[j - maxToTakeWithThisJAndThisArr - 1]
                                   : 0));
    }
  }
  return dp[n][k];
}
long long solve1(vector<long long> arr, long long n, long long k) {
  vector<vector<long long> > dp(n + 1, vector<long long>(k + 1, 0));
  dp[0][0] = 1LL;
  for (long long i = 0; i < arr.size(); i++) {
    vector<long long> ps(k + 1, 0);
    for (long long j = 0; j < k + 1; j++) {
      ps[j] = (dp[i][j] + (j - 1 >= 0 ? ps[j - 1] : 0)) % (long long)1000000007;
    }
    for (long long j = 0; j < k + 1; j++) {
      const auto maxToTakeWithThisJAndThisArr =
          ((arr[i]) < (j) ? (arr[i]) : (j));
      dp[i + 1][j] = (ps[j] - (j - maxToTakeWithThisJAndThisArr - 1 >= 0
                                   ? ps[j - maxToTakeWithThisJAndThisArr - 1]
                                   : 0));
    }
  }
  return dp[n][k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n, 0);
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long res = solve1(arr, n, k);
  cout << res << '\n';
  return 0;
}
