#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  long long int mod = 1e9 + 7;
  cin >> n;
  long long int k;
  cin >> k;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int ways[n + 1][k + 1], sum[n + 1][k + 1];
  for (long long int i = 0; i <= n; i++) {
    for (long long int j = 0; j <= k; j++) {
      ways[i][j] = 0;
      sum[i][j] = 0;
    }
  }
  sum[1][0] = 1;
  ways[1][0] = 1;
  for (long long int i = 1; i <= k; i++) {
    ways[1][i] = (i <= a[0]);
    sum[1][i] = sum[1][i - 1] + (i <= a[0]);
  }
  long long int sum1 = 0;
  sum1 = a[0];
  for (long long int i = 2; i <= n; i++) {
    sum1 += a[i - 1];
    for (long long int j = 0; j <= k; j++) {
      if (j <= sum1) {
        ways[i][j] = sum[i - 1][j];
        if (j - a[i - 1] > 0) {
          ways[i][j] -= sum[i - 1][j - a[i - 1] - 1];
        }
      }
      ways[i][j] %= mod;
      sum[i][j] = ways[i][j];
      if (j) {
        sum[i][j] += sum[i][j - 1];
      }
      sum[i][j] %= mod;
    }
  }
  cout << ways[n][k];
  return 0;
}
