#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<int> p(m + 1, 0);
  vector<vector<int>> dp(n + 1, p);
  dp[0][0] = 1;
  for (int i = 1; i < n + 1; i++) {
    long long sum = 0;
    int full = -1;
    for (int j = 0; j < m + 1; j++) {
      if (full < v[i - 1]) {
        sum = (sum + dp[i - 1][j]) % (1000000000 + 7);
        full++;
      } else
        sum = (sum +
               (dp[i - 1][j] - dp[i - 1][j - full - 1]) % (1000000000 + 7)) %
              (1000000000 + 7);
      dp[i][j] = (sum + dp[i][j]) % (1000000000 + 7);
    }
  }
  cout << dp[n][m];
  return 0;
}
