#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long n, c;
  cin >> n >> c;
  vector<long long> a(n), dp(c + 1);
  for (long long &i : a) cin >> i;
  dp[0] = 1;
  for (long long i = 0; i < n; i++) {
    vector<long long> p(c + 1);
    for (long long j = c; j >= 0; j--) {
      long long tmp = dp[j], L = j + 1, R = j + min(a[i], c - j);
      if (L <= R) {
        (p[L] += tmp) %= MOD;
        if (R + 1 <= c) {
          p[R + 1] -= tmp;
        }
      }
    }
    long long pref = 0;
    for (long long i = 0; i <= c; i++) {
      (pref += p[i]) %= MOD;
      (dp[i] += pref) %= MOD;
    }
  }
  cout << dp[c];
  return 0;
}
