#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long f[n];
  for (long long i = 0; i < n; i++) cin >> f[i];
  vector<vector<long long> > dp(n + 1, vector<long long>(k + 1));
  for (long long i = 0; i <= f[0]; i++) dp[1][i] = 1;
  for (long long i = 0; i <= n; i++) dp[i][0] = 1;
  for (long long i = 2; i <= n; i++) {
    for (long long j = 1; j <= k; j++) {
      dp[i][j] = dp[i][j] % 1000000007 + dp[i - 1][j] % 1000000007 +
                 dp[i][j - 1] % 1000000007;
      dp[i][j] %= 1000000007;
      if (j - f[i - 1] > 0)
        dp[i][j] = 1000000007 + dp[i][j] % 1000000007 -
                   dp[i - 1][j - f[i - 1]] % 1000000007;
      dp[i][j] %= 1000000007;
    }
  }
  cout << dp[n][k] % 1000000007;
  return 0;
}
