#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
long long ways(int a[], int n, int k) {
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  for (int i = 0; i <= n; i++) {
    dp[i][0] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) -
                 ((j - a[i - 1] - 1 >= 0) ? dp[i - 1][j - a[i - 1] - 1] : 0);
      dp[i][j] %= mod;
    }
  }
  return dp[n][k];
}
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << ways(a, n, k);
}
