#include <bits/stdc++.h>
using namespace std;
long long inf = 100000000000000000, mod = 1000000007;
int main() {
  long long n, k, sum = 0;
  cin >> n >> k;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long dp[n + 1][k + 1];
  for (long long i = 0; i < n + 1; i++)
    for (long long j = 0; j < k + 1; j++) dp[i][j] = 0;
  for (long long i = 0; i < n + 1; i++) dp[i][0] = 1;
  for (long long i = 1; i <= n; i++) {
    sum += arr[i - 1];
    for (long long j = 1; j <= k; j++) {
      if (j > sum) break;
      dp[i][j] = (dp[i][j] + (dp[i][j - 1] + dp[i - 1][j])) % mod;
      if (j - arr[i - 1] - 1 >= 0)
        dp[i][j] = (dp[i][j] - (dp[i][j - arr[i - 1] - 1]) + mod) % mod;
    }
  }
  cout << dp[n][k] << " ";
}
