#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e13 + 7;
const long long int mod = 1e9 + 7;
vector<vector<int>> dp;
long long int doSome(vector<long long int> &arr, int index, long long int k) {
  int n = arr.size();
  if (index == n) {
    if (k == 0) return 1;
    return 0;
  }
  if (k < 0) return 0;
  if (dp[index][k] != -1) return dp[index][k];
  long long int val = arr[index];
  if (index == n - 1) {
    val = arr[index];
  } else {
    val = arr[index] - arr[index + 1];
  }
  long long int ans = 0LL;
  for (int i = 0; i <= val; ++i) {
    if (arr[index] < k) return dp[index][k] = 0;
    ans += doSome(arr, index + 1, k - i);
    ans %= mod;
  }
  return dp[index][k] = ans;
}
void solv() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> arr(n);
  for (int i = 0; i <= n - 1; ++i) {
    cin >> arr[i];
  }
  dp.assign(n + 1, vector<int>(k + 1, -1));
  vector<long long int> preSum(n, 0);
  preSum[n - 1] = arr[n - 1];
  for (int i = n - 2; i >= 0; --i) {
    preSum[i] = preSum[i + 1] + arr[i];
  }
  long long int ans = doSome(preSum, 0, k);
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  solv();
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  ;
}
