#include <bits/stdc++.h>
using namespace std;
const int sz = 3e3 + 5;
long long inf = 1e15;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long ans = 0;
    long long ar[n + 1];
    for (int i = 1; i <= n; i++) {
      cin >> ar[i];
    }
    long long pre[k + 1], cur[k + 1];
    for (int i = 0; i <= k; i++) {
      pre[i] = 1;
      cur[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= k; j++) {
        if (j == 0) {
          cur[j] = 1;
        } else {
          long long low = 0;
          if (j - ar[i] - 1 >= 0) low = pre[j - ar[i] - 1] % 1000000007;
          cur[j] = (pre[j] % 1000000007 - low + 1000000007) % 1000000007;
          if (i == n and j == k) ans = cur[j];
        }
      }
      for (int j = 1; j <= k; j++) {
        cur[j] = (cur[j] % 1000000007 + cur[j - 1] % 1000000007) % 1000000007;
        ;
        pre[j] = cur[j];
      }
      for (int j = 1; j <= k; j++) cur[j] = 0;
    }
    cout << ans << "\n";
  }
  return 0;
}
