#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
inline int add(int a, int b) {
  long long int x = a;
  long long int y = b;
  return (x + y) % mod;
}
void Candies_DP(vector<int> &a, int totalCandies) {
  int n = a.size();
  vector<vector<int>> dp(n, vector<int>(totalCandies + 1, 0));
  vector<vector<int>> prefix(n, vector<int>(totalCandies + 1, 0));
  int i = 0;
  for (int j = 0; j <= totalCandies; j++) {
    if (a[0] >= j) dp[i][j] = 1;
    prefix[i][j] = dp[i][j];
    if (j != 0) prefix[i][j] = add(prefix[i][j], prefix[i][j - 1]);
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= totalCandies; j++) {
      int left = j - a[i];
      if (left < 0) left = 0;
      int right = j;
      dp[i][j] = add(dp[i][j], prefix[i - 1][right]);
      if (left != 0) dp[i][j] = add(dp[i][j], -1 * prefix[i - 1][left - 1]);
      prefix[i][j] = dp[i][j];
      if (j != 0) prefix[i][j] = add(prefix[i][j], prefix[i][j - 1]);
    }
  }
  cout << dp[n - 1][totalCandies] << endl;
}
int main() {
  int n, totalCandies;
  cin >> n >> totalCandies;
  vector<int> a(n);
  for (auto &ele : a) cin >> ele;
  Candies_DP(a, totalCandies);
  return 0;
}
