#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000007;
const long long int linf = 1ll * inf * inf;
inline long long int mul(long long int a, long long int b) {
  return (a * 1ll * b) % 1000000007;
}
inline long long int sub(long long int a, long long int b) {
  long long int c = a - b;
  if (c < 0) c += 1000000007;
  return c;
}
inline long long int add(long long int a, long long int b) {
  long long int c = a + b;
  if (c > 1000000007) c -= 1000000007;
  return c;
}
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2>& p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  t = 1;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    vector<long long int> a(n);
    for (long long int i = 0; i < n; i++) cin >> a[i];
    long long int dp[k + 1];
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    for (long long int i = 0; i < n; i++) {
      vector<long long int> fake(k + 1, 0);
      for (long long int used = k; used >= 0; used--) {
        long long int l = used + 1;
        long long int r = used + min(a[i], k - used);
        if (l <= r) {
          fake[l] = add(fake[l], dp[used]);
          if (r + 1 <= k) {
            fake[r + 1] = sub(fake[r + 1], dp[used]);
          }
        }
      }
      long long int sum = 0;
      for (long long int j = 0; j <= k; j++) {
        sum = add(sum, fake[j]);
        dp[j] = add(dp[j], sum);
      }
    }
    cout << dp[k] << "\n";
  }
}
