#include <bits/stdc++.h>
using namespace std;
long long n, k, *arr;
long long mod = 1e9 + 7LL;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2>& p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
  size_t operator()(const pair<uint64_t, uint64_t>& p) const {
    auto hash1 = custom_hash{}(p.first);
    auto hash2 = custom_hash{}(p.second);
    return hash1 ^ (hash2 >> 1);
  }
};
unordered_map<pair<long long, long long>, long long, hash_pair> dp;
long long NumberOfways(long long k, long long st) {
  if (k < 0LL) return 0LL;
  if (st == n) {
    if (k == 0) {
      return 1LL;
    }
    return 0LL;
  }
  if (dp.find({k, st}) != dp.end()) return dp[{k, st}];
  long long ans = 0LL;
  for (long long i = 0; (0 <= arr[st]) ? i <= arr[st] : i >= arr[st];
       (0 <= arr[st]) ? i++ : i--) {
    ans += NumberOfways(k - i, st + 1LL);
    ans %= mod;
  }
  dp[{k, st}] = ans;
  return ans;
}
void solve() {
  cin >> n >> k;
  arr = new long long[sizeof(long long) * n];
  for (long long i = 0; (0 <= n - 1) ? i <= n - 1 : i >= n - 1;
       (0 <= n - 1) ? i++ : i--)
    cin >> arr[i];
  cout << NumberOfways(k, 0LL) << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
