#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
inline int fast_expo(int base, int power, int modulo = mod) {
  base %= modulo;
  if (base < 0) base += modulo;
  long long x = base, cnt = power, ans = 1;
  while (cnt) {
    if (cnt & 1) ans = (ans * x) % modulo;
    x = (x * x) % modulo;
    cnt >>= 1;
  }
  return ans;
}
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int first = 0;
  cerr << '{';
  for (auto &i : x) cerr << (first++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const int INF = (int)1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> arr(n);
  long long k;
  cin >> k;
  for (int i = (0); i < long long(long long(n)); ++i) cin >> arr[i];
  long long dp[n][k + 1];
  dp[0][0] = 1;
  long long pre[n][k + 1];
  pre[0][0] = 1;
  for (int i = (1); i < long long(k + 1); ++i) {
    if (i < arr[0] + 1) {
      dp[0][i] = 1;
    } else {
      dp[0][i] = 0;
    }
    pre[0][i] = (pre[0][i - 1] + dp[0][i]) % mod;
  }
  for (int i = (0); i < long long(long long(n)); ++i) {
    dp[i][0] = 1;
  }
  for (int i = (1); i < long long(n); ++i) {
    pre[i][0] = 1;
    for (int j = (1); j < long long(k + 1); ++j) {
      if (j - arr[i] < 1) {
        dp[i][j] = pre[i - 1][j] % mod;
      } else {
        dp[i][j] = (pre[i - 1][j] - pre[i - 1][j - arr[i] - 1]) % mod;
      }
      pre[i][j] = (pre[i][j - 1] + dp[i][j]) % mod;
    }
  }
  cout << dp[n - 1][k] % mod << endl;
  return 0;
}
