#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1));
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= k; i++) {
    dp[1][i] = 1;
  }
  for (int i = 2; i <= n; i++) {
    dp[i][0] = dp[i - 1][0];
    for (int j = 1; j <= k; j++) {
      if (j <= a[i - 1])
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
      else
        dp[i][j] = (dp[i][j - 1]) % mod;
    }
  }
  cout << dp[n][k] << '\n';
  return 0;
}
