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