#include <bits/stdc++.h>
using namespace std;
int a[100005];
long int dp[100005][105], sum[100005][105];
long int range(int i, int j) {
  if (i >= 0 && j >= 0) return sum[i][j];
  return 0;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (i == 0 && j == 0)
        dp[i][j] = 1;
      else if (i && j == 0)
        dp[i][j] = 0;
      else {
        if (i >= a[j - 1])
          dp[i][j] =
              (range(i, j - 1) - range(i - a[j - 1] - 1, j - 1)) % 1000000007;
        else
          dp[i][j] = range(i, j - 1) % 1000000007;
      }
      sum[i][j] = (dp[i][j] + range(i - 1, j)) % 1000000007;
    }
  }
  printf("%ld\n", dp[k][n]);
  return 0;
}
