#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
bool mod(long double a, long double b) { return a / b - floor(a / b); }
long long ceil(long long n, long long k) {
  if (k % n == 0) {
    return k / n;
  } else
    return (k / n) + 1;
}
long long occurs(vector<long long> v, long long n) {
  auto it = lower_bound(((v)).begin(), ((v)).end(), (n));
  auto it1 = upper_bound(((v)).begin(), ((v)).end(), (n));
  long long first = it1 - it;
  return first;
}
long long logb(long long base, long long first) {
  return (log(first) / log(base));
}
long long a[3005], dp[3005][3005];
long long candies(long long n, long long k) {
  long long i;
  if (k < 0)
    return 0;
  else if (dp[n][k] != -1)
    return dp[n][k];
  else if (n == 1) {
    if (k <= a[1]) {
      dp[n][k] = 1;
    } else
      dp[n][k] = 0;
    return dp[n][k];
  } else {
    dp[n][k] = 0;
    for (i = 0; i < a[n] + 1; i++)
      dp[n][k] = (dp[n][k] + candies(n - 1, k - i)) % 1000000007;
    return dp[n][k];
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long i, j, first, t, n, k;
  cin >> n >> k;
  memset(a, -1, sizeof(a));
  memset(dp, -1, sizeof(dp));
  a[0] = 0;
  for (i = 0; i < n; i++) {
    cin >> first;
    a[i + 1] = first;
  }
  cout << candies(n, k) << '\n';
  return 0;
}
