#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const long long LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
template <typename T>
T gcd(T a, T b) {
  return (a == 0) ? b : gcd(b % a, a);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
bool p_comp_fs(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first < p2.first;
};
bool p_comp_fg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first > p2.first;
};
bool p_comp_ss(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second < p2.second;
};
bool p_comp_sg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second > p2.second;
};
template <typename T>
vector<T> uniquen(vector<T> vec) {
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) cin >> A[i];
  const long long mod = 1e9 + 7;
  vector<vector<long long> > dp(N + 1, vector<long long>(K + 1, 0));
  dp[0][0] = 1;
  for (long long i = 0; i < N; i++) {
    vector<long long> sum(K + 2, 0);
    for (long long j = 0; j < K + 1; j++) {
      sum[j + 1] = (sum[j] + dp[i][j]) % mod;
    }
    for (long long j = 0; j < K + 1; j++) {
      if (j < A[i])
        dp[i + 1][j] = sum[j + 1];
      else
        dp[i + 1][j] = sum[j + 1] - sum[j - A[i]];
    }
  }
  cout << dp[N][K] << endstr;
  return 0;
}
