#include <bits/stdc++.h>
using namespace std;
vector<long long int> V, sum;
long long int dp[100005][105];
long long int fun(long long int n, long long int i) {
  if (n > sum[i]) return 0;
  int j;
  if (i == 0) {
    if (n <= V[0]) {
      dp[n][i] = 1;
      return 1;
    } else {
      dp[n][i] = 0;
      return 0;
    }
  } else {
    long long int sum = 0;
    for (j = 0; j <= V[i]; j++) {
      if (j <= n) {
        if (dp[n - j][i - 1] == -1) dp[n - j][i - 1] = fun(n - j, i - 1);
        sum = (sum % 1000000007 + dp[n - j][i - 1] % 1000000007) % 1000000007;
      } else
        break;
    }
    dp[n][i] = sum % 1000000007;
    return dp[n][i];
  }
}
int main() {
  long long int N, K, i, j, x;
  cin >> N >> K;
  long long int l = 0;
  for (i = 0; i < N; i++) {
    cin >> x;
    V.push_back(x);
    l += x;
    sum.push_back(l);
  }
  for (i = 0; i < 100005; i++) {
    for (j = 0; j < 105; j++) dp[i][j] = -1;
  }
  dp[K][N - 1] = fun(K, N - 1) % 1000000007;
  cout << dp[K][N - 1] << endl;
  return 0;
}
