#include <bits/stdc++.h>
using namespace std;
int f(int n, int k, int a[]) {
  long long dp[n + 2][k + 2];
  for (int j = 0; j <= k; j++) dp[1][j] = (j > a[1]) ? 0 : 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      if (j == 0)
        dp[i][j] = dp[i - 1][j];
      else {
        dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] -
                    ((j - a[i] - 1 >= 0) ? dp[i - 1][j - a[i] - 1] : 0)) %
                   1000000007;
      }
    }
  }
  return dp[n][k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  cout << f(n, k, a);
  return 0;
}
