#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
long long pow(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++) cin >> a[i];
    long long dp[n + 1][k + 1];
    long long prevprefixsum[k + 1];
    for (int i = 0; i <= k; i++) dp[0][i] = 0, prevprefixsum[i] = 1;
    for (int i = 1; i <= n; i++) dp[i][0] = 1;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= k; j++) {
        if (j <= a[i])
          dp[i][j] = prevprefixsum[j];
        else
          dp[i][j] = prevprefixsum[j] - prevprefixsum[j - a[i] - 1];
        dp[i][j] %= MOD;
      }
      for (int j = 1; j <= k; j++)
        prevprefixsum[j] = (dp[i][j] + prevprefixsum[j - 1]) % MOD;
    }
    cout << dp[n][k];
    cout << "\n";
  }
}
