#include <bits/stdc++.h>
using namespace std;
long long int maxi(long long int a, long long int b) {
  if (a >= b) return a;
  return b;
}
long long int mini(long long int a, long long int b) {
  if (a <= b) return a;
  return b;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<long long int> arr(n, 0);
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<long long int> a(k + 1, 0);
  a[0] = 1;
  for (int i = 0; i < n; i++) {
    vector<long long int> b(k + 1, 0);
    b[0] = a[0];
    long long int sum = a[0];
    for (int j = 1; j <= k; j++) {
      sum = (sum + a[j]) % 1000000007;
      b[j] = sum;
    }
    for (int j = 1; j <= k; j++) {
      if (j <= arr[i]) {
        a[j] = b[j];
      } else {
        a[j] = b[j] - b[j - arr[i] - 1];
      }
    }
  }
  cout << a[k] << endl;
}
