#include <bits/stdc++.h>
using namespace std;
int binarySearch(vector<int> input, int target) {
  int start = 0;
  int end = input.size() - 1;
  int result = -1;
  while (start <= end) {
    int mid = end - (end - start) / 2;
    if (input[mid] == target) {
      result = mid;
      start = mid + 1;
    } else if (input[mid] > target) {
      end = mid - 1;
    } else {
      start = mid + 1;
    }
  }
  return result;
}
int lis(vector<int> v, int n, int maxVal) {
  if (n == 0) return 0;
  if (v[n - 1] < maxVal) {
    return max(1 + lis(v, n - 1, v[n - 1]), lis(v, n - 1, maxVal));
  } else
    return lis(v, n - 1, maxVal);
}
void sw(string &s, int i, int j) {
  char temp = s[i];
  s[i] = s[j];
  s[j] = temp;
}
void swap(string &s, int i, int j) {
  for (int l = j; l > i; l--) {
    sw(s, l, l - 1);
  }
}
int get(int n) {
  if (n % 2 == 1) return n;
  return get(n / 2);
}
void dfs(vector<vector<int>> &graph, vector<bool> &visited, int start, int curr,
         int &max) {
  if (visited[start]) return;
  visited[start] = true;
  for (auto i : graph[start]) {
    dfs(graph, visited, i, curr + 1, max);
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp[n + 1][k + 1];
  int psum[n + 1][k + 1];
  for (int i = 1; i < k + 1; i++) {
    dp[0][i] = 0;
    psum[0][i] = 1;
  }
  for (int i = 0; i < n + 1; i++) {
    dp[i][0] = 1;
    psum[i][0] = 1;
  }
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < k + 1; j++) {
      int temp = j - a[i - 1];
      if (temp < 0) temp = 0;
      dp[i][j] = (psum[i - 1][j] % 1000000007 - psum[i - 1][temp] % 1000000007 +
                  1000000007 + dp[i - 1][temp] % 1000000007) %
                 1000000007;
      psum[i][j] =
          (dp[i][j] % 1000000007 + psum[i][j - 1] % 1000000007) % 1000000007;
    }
  }
  cout << dp[n][k] << "\n";
}
