#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, sum = 0, md = 1000000007;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp[n + 1][k + 1];
  for (int i = 0; i <= n; i++) dp[i][0] = 1;
  for (int i = 1; i <= k; i++) dp[0][i] = 0;
  for (int i = 1; i <= n; i++) {
    sum = sum + a[i - 1];
    for (int j = 1; j <= k; j++) {
      if (j > sum)
        dp[i][j] = 0;
      else if (sum == j)
        dp[i][j] = 1;
      else {
        if (j <= a[i - 1])
          dp[i][j] = (dp[i - 1][j] % md + dp[i][j - 1] % md) % md;
        else if (j > a[i - 1])
          dp[i][j] = max(dp[i][j - 1] % md, dp[i - 1][j] % md) % md;
      }
    }
  }
  cout << dp[n][k] % md << "\n";
  return 0;
}
