#include <bits/stdc++.h>
using namespace std;
long long int dp[100001][101];
int main() {
  long long int n, k;
  cin >> n >> k;
  memset(dp, 0, sizeof dp);
  long long int a[101];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) dp[i][0] = 1;
  long long int sum = a[0];
  for (int i = 0; i <= a[0]; i++) {
    dp[i][0] = 1;
  }
  for (long long int i = 1; i < n; i++) {
    sum = (sum % 1000000007 + a[i] % 1000000007) % 1000000007;
    for (long long int j = 1; j <= k && j <= sum; j++) {
      dp[j][i] =
          (dp[j - 1][i] % 1000000007 + dp[j][i - 1] % 1000000007) % 1000000007;
    }
  }
  long long int ans = 0;
  for (long long int i = 0; i <= k; i++)
    ans = (ans % 1000000007 + dp[k][n - 1] % 1000000007) % 1000000007;
  cout << ans << endl;
  return 0;
}
