#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];
  }
  long long int dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  long long int sum[n + 1][k + 1];
  memset(sum, 0, sizeof(sum));
  for (int j = 0; j < n + 1; j++) {
    dp[j][0] = 1;
    sum[j][0] = 1;
  }
  for (int i = 0; i < k + 1; i++) {
    sum[0][i] = 1;
  }
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < k + 1; j++) {
      if (j <= a[i - 1]) {
        dp[i][j] = sum[i - 1][j] % 1000000007;
      } else {
        dp[i][j] = ((sum[i - 1][j] % 1000000007) -
                    sum[i - 1][j - a[i - 1] - 1] % 1000000007) %
                   1000000007;
      }
    }
    for (int l = 1; l < k + 1; l++) {
      sum[i][l] = sum[i][l - 1] % 1000000007 + dp[i][l] % 1000000007;
    }
  }
  cout << dp[n][k] % 1000000007 << endl;
}
