#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printVector(const vector<T>& vec) {
  for (const T x : vec) {
    cout << x << " ";
  }
  cout << endl;
}
template <typename T>
void printMatrix(const vector<vector<T> >& mat) {
  for (const vector<T> vec : mat) {
    printVector(vec);
  }
  cout << endl;
}
const long long INF = 1e18L + 5;
template <typename T>
void min_self(T& a, T b) {
  a = min(a, b);
}
template <typename T>
void max_self(T& a, T b) {
  a = max(a, b);
}
template <typename T>
void add_self(T& a, T b) {
  a += b;
  if (a >= 1e9 + 7) {
    a -= 1e9 + 7;
  }
}
template <typename T>
void sub_self(T& a, T b) {
  a -= b;
  if (a < 0) {
    a += 1e9 + 7;
  }
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> a(n);
  for (int& x : a) scanf("%d", &x);
  vector<int> dp(k + 1);
  dp[0] = 1;
  for (int child = 0; child < n; child++) {
    vector<int> vec(k + 1, 0);
    for (int used = k; used >= 0; used--) {
      int to = min(a[child], k - used);
      int y = used + 1, z = used + to;
      int temp = dp[used];
      add_self(vec[y], temp);
      if (z < k) sub_self(vec[z + 1], temp);
    }
    int prefix_sum = 0;
    for (int i = 0; i <= k; i++) {
      add_self(prefix_sum, vec[i]);
      add_self(dp[i], prefix_sum);
    }
  }
  printf("%d\n", dp[k]);
  return 0;
}
