#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (x == 0) return y;
  return gcd(y % x, x);
}
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
long long squ(long long n, long long p, long long m) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    long long t = squ(n, p / 2, m);
    return t * t % m;
  }
  return n * squ(n, p - 1, m);
}
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
long long fac[510000], finv[510000], inv[510000];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < 510000; i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
    inv[i] = 1000000007 - inv[1000000007 % i] * (1000000007 / i) % 1000000007;
    finv[i] = finv[i - 1] * inv[i] % 1000000007;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % 1000000007) % 1000000007;
}
long long com(long long n, long long m) {
  if (n <= 0 || m <= 0 || n == m) {
    return 1;
  }
  if (n < m) {
    return 0;
  }
  long long k = 1;
  for (long long i = 1; i <= m; i++) {
    k *= (n - i + 1);
    k %= 1000000007;
    k *= modinv(i, 1000000007);
    k %= 1000000007;
  }
  return k;
}
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long dp[n + 1][k + 1];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = 0;
    }
  }
  for (long long i = 0; i <= k; i++) {
    if (i <= a[1]) {
      dp[1][i] = i + 1;
    } else {
      dp[1][i] = dp[1][i - 1];
    }
  }
  long long sum = a[1];
  for (int i = 1; i <= n - 1; i++) {
    sum += a[i + 1];
    for (int j = 0; j <= min(sum, k); j++) {
      if (j - a[i + 1] - 1 >= 0) {
        dp[i + 1][j] = dp[i][j] - dp[i][j - a[i + 1] - 1];
        dp[i + 1][j] %= 1000000007;
      } else {
        dp[i + 1][j] = dp[i][j];
        dp[i + 1][j] %= 1000000007;
      }
    }
    for (int j = 1; j <= k; j++) {
      dp[i + 1][j] += dp[i + 1][j - 1];
      dp[i + 1][j] %= 1000000007;
    }
  }
  if (k >= 1) {
    cout << dp[n][k] - dp[n][k - 1] << endl;
  } else {
    cout << dp[n][k] << endl;
  }
  return 0;
}
