#include <bits/stdc++.h>
using namespace std;
long long powmod(long long base, long long exp, long long MOD) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % MOD;
    base = (base * base) % MOD;
    exp /= 2;
  }
  return (res % MOD);
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  for (int i = 0; i <= k; ++i) {
    dp[1][i] = (i <= a[0] ? 1 : 0);
  }
  for (int i = 2; i <= n; ++i) {
    for (int j = 0; j <= k; ++j) {
      dp[i][j] = ((j >= 1 ? dp[i][j - 1] : 0) + dp[i - 1][j] -
                  (j - 1 - a[i - 1] >= 0 ? dp[i - 1][j - 1 - a[i - 1]] : 0)) %
                 1000000007;
    }
  }
  cout << dp[n][k] << endl;
}
