#include <bits/stdc++.h>
using namespace std;
void normal(long long &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
long long modInverse(long long a) { return modPow(a, 1000000007 - 2); }
long long modDiv(long long a, long long b) { return modMul(a, modInverse(b)); }
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> dp(k + 1, 0);
  dp[0] = 1;
  for (int child = 0; child < n; ++child) {
    int up_to;
    cin >> up_to;
    vector<int> dp2(k + 1, 0);
    for (int used = k; used >= 0; --used) {
      int L = used + 1, R = used + min(up_to, k - used);
      if (L > R) continue;
      dp2[L] = modAdd(dp2[L], dp[used]);
      dp2[R + 1] = modSub(dp2[R + 1], dp[used]);
    }
    for (int i = 0; i <= k; ++i) {
      dp2[i] = modAdd(dp2[i], dp2[i - 1]);
      dp[i] = modAdd(dp[i], dp2[i]);
    }
  }
  cout << dp[k] << endl;
  return 0;
}
