#include <bits/stdc++.h>
using namespace std;
int bs_upper_bound(int a[], int n, int x) {
  int l = 0;
  int h = n;
  while (l < h) {
    int mid = l + (h - l) / 2;
    if (x >= a[mid]) {
      l = mid + 1;
    } else {
      h = mid;
    }
  }
  return l;
}
int bs_lower_bound(int a[], int n, int x) {
  int l = 0;
  int h = n;
  while (l < h) {
    int mid = l + (h - l) / 2;
    if (x <= a[mid]) {
      h = mid;
    } else {
      l = mid + 1;
    }
  }
  return l;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
long long n, k;
vector<long long> a;
long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  long long dp[k + 2];
  for (int i = 0; i <= k; i++) dp[i] = 0;
  dp[0] = 1;
  long long t[k + 2];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k + 1; j++) t[j] = 0;
    for (int j = k; j >= 0; j--) {
      int l = j + 1;
      int r = min(j + a[i], k);
      t[l] = (t[l] + dp[j]) % mod;
      t[r + 1] = (t[r + 1] - dp[j]) % mod;
    }
    long long p = 0;
    for (int j = 0; j <= k; j++) {
      p = (p + t[j]) % mod;
      dp[j] = (dp[j] + p) % mod;
    }
  }
  cout << dp[k];
}
