#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void add_self(int& a, int b) {
  a += b;
  a -= a >= 1e9 + 5 ? 1e9 + 5 : 0;
}
void sub_self(int& a, int b) {
  a -= b;
  a += a < 0 ? 1e9 + 5 : 0;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> dp(k + 1);
  dp[0] = 1;
  while (n--) {
    int up_to;
    scanf("%d", &up_to);
    vector<int> fake(k + 1);
    for (int used = k; used >= 0; used--) {
      int l = used + 1;
      int r = used + min(up_to, k - used);
      int tmp = dp[used];
      if (l <= r) {
        add_self(fake[l], tmp);
        if (r + 1 <= k) {
          sub_self(fake[r + 1], tmp);
        }
      }
    }
    int prefixe_sum = 0;
    for (int i = 0; i <= k; i++) {
      add_self(prefixe_sum, fake[i]);
      add_self(dp[i], prefixe_sum);
    }
  }
  printf("%d\n", dp[k]);
}
