#include <bits/stdc++.h>
using namespace std;
inline long long int max(long long int a, long long int b) {
  return a > b ? a : b;
}
inline long long int min(long long int a, long long int b) {
  return a < b ? a : b;
}
const long long inf = 9e18;
double pie = 2 * acos(0.0);
void show(vector<long long int> v) {
  for (long long int i = 0; i < (v.size()); ++i) cout << v[i] << " ";
  cout << "\n";
}
void show(vector<int> v) {
  for (long long int i = 0; i < (v.size()); ++i) cout << v[i] << " ";
  cout << "\n";
}
void show(int a[], int arraysize) {
  for (int i = 0; i < arraysize; ++i) cout << a[i] << " ";
  cout << "\n";
}
void show(long long int a[], long long int arraysize) {
  for (long long int i = 0; i < arraysize; ++i) cout << a[i] << " ";
  cout << "\n";
}
void show(bool a[], long long int arraysize) {
  for (long long int i = 0; i < arraysize; ++i) cout << a[i] << " ";
  cout << "\n";
}
void show(set<int> s) {
  for (auto it = s.begin(); it != s.end(); it++) {
    cout << *it << " ";
  }
  cout << "\n";
}
void show(map<long long int, long long int> mp) {
  for (auto it = mp.begin(); it != mp.end(); it++) {
    cout << it->first << " " << it->second << "\n";
  }
  cout << "\n";
}
long long int modpow(long long int x, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1) res = ((res % 1000000007) * (x % 1000000007)) % 1000000007;
    x = ((x % 1000000007) * (x % 1000000007)) % 1000000007;
    n >>= 1;
  }
  return res;
}
long long int power(long long int x, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n);
  vector<vector<long long int> > dp(n, vector<long long int>(k + 1));
  vector<vector<long long int> > pf(n, vector<long long int>(k + 1));
  for (long long int i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  for (long long int i = 0; i < (n); ++i) {
    for (long long int j = 0; j < (k + 1); ++j) {
      if (i == 0) {
        if (j <= a[i])
          dp[i][j] = 1;
        else
          dp[i][j] = 0;
      } else if (j == 0)
        dp[i][j] = dp[i - 1][j];
      else {
        dp[i][j] = pf[i - 1][min(j, a[i - 1])];
      }
    }
    long long int s = 0;
    for (long long int j = 0; j < (k + 1); ++j) {
      s += dp[i][j];
      s %= 1000000007;
      pf[i][j] = s;
    }
  }
  cout << dp[n - 1][k] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);
  int t;
  t = 1;
  while (t) {
    solve();
    t--;
  }
  return 0;
}
