#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];
  }
  vector<vector<long long>> dp(N, vector<long long>(K + 1, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= K; j++) {
      if (i == 0 and j <= a[0]) dp[i][j] = 1;
      if (j == 0) dp[i][j] = 1;
    }
  }
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      int x = j;
      int y = a[i];
      while (x >= 0 and y >= 0) {
        dp[i][j] =
            (dp[i][j] % 1000000007 + dp[i - 1][x] % 1000000007) % 1000000007;
        x--;
        y--;
      }
    }
  }
  cout << dp[N - 1][K] % 1000000007;
}
