#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    a.push_back(temp);
  }
  long long int dp[k + 1][n];
  for (int sum = k; sum >= 0; sum--) {
    if (sum <= a[n - 1]) {
      dp[sum][n - 1] = 1;
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    for (int sum = k; sum >= 0; sum--) {
      dp[sum][i] = 0;
      for (int z = 0; z < a[i] + 1; z++) {
        if (sum - z >= 0) {
          dp[sum][i] += dp[sum - z][i + 1];
          dp[sum][i] = dp[sum][i] % 1000000007;
        }
      }
    }
  }
  cout << dp[4][0] << "\n";
}
