#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b % 2 != 0) {
      ans = ((ans) * (a));
    }
    a = ((a) * (a));
    b = b / 2;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n + 1);
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<vector<long long int>> dp(n + 1, vector<long long int>(k + 1, 0));
  vector<vector<long long int>> pre(n + 1, vector<long long int>(k + 1, 0));
  for (long long int i = 0; i <= n; i++) {
    dp[i][0] = 1;
    pre[i][0] = 1;
  }
  pre[0][0] = 1;
  for (long long int j = 1; j <= k; j++) {
    pre[0][j] = 1;
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= k; j++) {
      if (j - a[i] >= 1) {
        dp[i][j] = ((pre[i - 1][j]) % 1000000007 -
                    (pre[i - 1][j - a[i] - 1]) % 1000000007) %
                   1000000007;
      } else
        dp[i][j] = pre[i - 1][j] % 1000000007;
      while (dp[i][j] > 1000000007) dp[i][j] = dp[i][j] % 1000000007;
      pre[i][j] =
          ((dp[i][j] % 1000000007 + pre[i][j - 1] % 1000000007)) % 1000000007;
      while (pre[i][j] > 1000000007) pre[i][j] = pre[i][j] % 1000000007;
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
