#include <bits/stdc++.h>
using namespace std;
long long n, i, j, ans = 0, k;
long long a[1000], dp[100 + 3][100000 + 9];
long long M = (long long)1E9 + 7;
long long f(long long st, long long choc) {
  if (st > n) {
    if (choc == 0)
      return 1;
    else
      return 0;
  }
  if (dp[st][choc] != -1) return dp[st][choc];
  dp[st][choc] = 0;
  for (int i = 0; i <= min(a[st], choc); i++)
    dp[st][choc] = (dp[st][choc] + f(st + 1, choc - i) + M) % M;
  return dp[st][choc] % M;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i <= a[1]; i++) dp[1][i] = 1;
  for (int i = 2; i <= n; i++) {
    dp[i][0] = 1;
    long long sum = 1;
    for (int j = 1; j <= a[i]; j++) {
      dp[i][j] = (sum + dp[i - 1][j] + M) % M;
      sum = (sum + dp[i - 1][j] + M) % M;
    }
    sum = (sum - 1 + M) % M;
    long long k1 = 1;
    for (int j = 1 + a[i]; j <= 100000; j++) {
      sum = (sum + dp[i - 1][j] + M) % M;
      dp[i][j] = (sum + M) % M;
      sum = (sum + dp[i - 1][j] - dp[i - 1][k1++] + M) % M;
    }
  }
  cout << (dp[n][k] + M) % M << endl;
}
