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