#include <bits/stdc++.h>
using namespace std;
int count(vector<int> &ar, int cur, int k, vector<vector<int>> &dp) {
  if (k == 0) {
    return 1;
  }
  if (cur == ar.size() or k < 0) {
    return 0;
  }
  int presentCount = 0;
  for (int i = 0; i <= ar[cur]; i++) {
    if (k - i >= 0 and dp[cur + 1][k - i] != -1) {
      presentCount = (presentCount + dp[cur + 1][k - i]) % 1000000007;
    } else {
      presentCount =
          (presentCount + count(ar, cur + 1, k - i, dp)) % 1000000007;
    }
  }
  dp[cur][k] = presentCount;
  return presentCount;
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> ar;
  int data;
  for (int i = 0; i < n; i++) {
    cin >> data;
    ar.push_back(data);
  }
  vector<vector<int>> dp(n + 1, vector<int>(k + 1, -1));
  cout << count(ar, 0, k, dp);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  {
    solve();
    t--;
  }
  return 0;
}
