// Original C++ solution (slower):
#include <bits/stdc++.h>

#define int long long int

using namespace std;

template<typename T,typename U> using P=pair<T,U>;

template<typename T> using V=vector<T>;

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}

template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}



template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}

template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}

template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}

template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;



struct edge { int to, cost; };



const int INF = 1e18;

const int MOD = 1e9+7;



struct ModRing {

   int mod, x;

   ModRing(int mod_n) : mod(mod_n), x(0) {}

   ModRing(int a, int mod_n) : mod(mod_n) { x = ((a % mod) + mod) % mod; }



   bool operator==(const ModRing& a) const {

      return x == a.x;

   }

   bool operator==(int a) const {

      return *this == ModRing(a, mod);

   }

   ModRing& operator=(int a) {

      return *this = ModRing(a, mod);

   }

   ModRing operator-() const {

      return ModRing((-x + mod) % mod, mod);

   }

   ModRing& operator+=(const ModRing& a) {

      (x += a.x) %= mod;

      return *this;

   }

   ModRing& operator-=(const ModRing& a) {

      return *this += -a;

   }

   ModRing& operator*=(const ModRing& a) {

      (x *= a.x) %= mod;

      return *this;

   }

   const ModRing operator+(const ModRing& a) const {

      return ModRing(x, mod) += a;

   }

   const ModRing operator-(const ModRing& a) const {

      return ModRing(x, mod) -= a;

   }

   const ModRing operator*(const ModRing& a) const {

      return ModRing(x, mod) *= a;

   }

   ModRing& operator+=(int a) {

      return *this += ModRing(a, mod);

   }

   ModRing& operator-=(int a) {

      return *this -= ModRing(a, mod);

   }

   ModRing& operator*=(int a) {

      return *this *= ModRing(a, mod);

   }

   const ModRing operator+(int a) const {

      return ModRing(x, mod) += a;

   }

   const ModRing operator-(int a) const {

      return ModRing(x, mod) -= a;

   }

   const ModRing operator*(int a) const {

      return ModRing(x, mod) *= a;

   }

   ModRing power(int n) const {

      ModRing tmp(x, mod), res(1, mod);

      while (n > 0) {

         if ((n & 1) == 1) res *= tmp;

         tmp *= tmp;

         n >>= 1;

      }

      return res;

   }

};

auto&operator<<(ostream&s,const ModRing&a){s<<a.x;return s;}



struct FiniteField : ModRing {

   FiniteField(int mod_n) : ModRing(mod_n) {}

   FiniteField(int a, int mod_n) : ModRing(a, mod_n) {}

   FiniteField(const ModRing& a) : ModRing(a) {}



   bool operator==(const FiniteField& a) const {

      return ModRing::operator==(a);

   }

   bool operator==(int a) const {

      return ModRing::operator==(a);

   }

   FiniteField& operator=(int a) {

      return *this = FiniteField(ModRing::operator=(a));

   }

   FiniteField operator-() const {

      return FiniteField(ModRing::operator-());

   }

   FiniteField& operator+=(const FiniteField& a) {

      return *this = FiniteField(ModRing::operator+=(a));

   }

   FiniteField& operator-=(const FiniteField& a) {

      return *this = FiniteField(ModRing::operator-=(a));

   }

   FiniteField& operator*=(const FiniteField& a) {

      return *this = FiniteField(ModRing::operator*=(a));

   }

   const FiniteField operator+(const FiniteField& a) const {

      return FiniteField(ModRing::operator+(a));

   }

   const FiniteField operator-(const FiniteField& a) const {

      return FiniteField(ModRing::operator-(a));

   }

   const FiniteField operator*(const FiniteField& a) const {

      return FiniteField(ModRing::operator*(a));

   }

   FiniteField& operator+=(int a) {

      return *this = FiniteField(ModRing::operator+=(a));

   }

   FiniteField& operator-=(int a) {

      return *this = FiniteField(ModRing::operator-=(a));

   }

   FiniteField& operator*=(int a) {

      return *this = FiniteField(ModRing::operator*=(a));

   }

   const FiniteField operator+(int a) const {

      return FiniteField(ModRing::operator+(a));

   }

   const FiniteField operator-(int a) const {

      return FiniteField(ModRing::operator-(a));

   }

   const FiniteField operator*(int a) const {

      return FiniteField(ModRing::operator*(a));

   }

   FiniteField power(int n) const {

      return FiniteField(ModRing::power(n));

   }



   FiniteField inverse() const {

      try { if (x == 0) throw "0 have no inverse"; }

      catch (const char* e) { cerr << e << endl; }

      return power(mod-2);

   }

   FiniteField& operator/=(const FiniteField& a) {

      return *this *= a.inverse();

   }

   const FiniteField operator/(const FiniteField& a) const {

      return FiniteField(x, mod) /= a;

   }

   FiniteField& operator/=(int a) {

      return *this /= FiniteField(a, mod);

   }

   const FiniteField operator/(int a) const {

      return FiniteField(x, mod) /= a;

   }

};



int GF_MOD = MOD;

struct GF : FiniteField {

   GF() : FiniteField(GF_MOD) {}

   GF(int a) : FiniteField(a, GF_MOD) {}

   GF(const FiniteField& a) : FiniteField(a) {}

};



signed main()

{

   int n, K; cin >> n >> K;

   V<int> a(n);

   for (int i = 0; i < n; i++) {

      cin >> a[i];

   }



   V<V<GF>> dp(n+1, V<GF>(K+1));

   V<V<GF>> sum(n+1, V<GF>(K+2));

   dp[0][0] = 1;

   for (int k = 0; k <= K; k++) {

      sum[0][k+1] = sum[0][k] + dp[0][k];

   }

   for (int i = 0; i < n; i++) {

      for (int k = 0; k <= K; k++) {

         dp[i+1][k] = sum[i][k+1] - sum[i][max(k-a[i], 0LL)];

         sum[i+1][k+1] = sum[i+1][k] + dp[i+1][k];

      }

   }

   cout << dp[n][K] << endl;



   return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define int long long int

using namespace std;

template<typename T,typename U> using P=pair<T,U>;

template<typename T> using V=vector<T>;

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}

template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}



template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}

template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}

template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}

template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;



struct edge { int to, cost; };



const int INF = 1e18;

const int MOD = 1e9+7;



signed main()

{

   int n, K; cin >> n >> K;

   V<int> a(n);

   for (int i = 0; i < n; i++) {

      cin >> a[i];

   }



   V<V<int>> dp(n+1, V<int>(K+1));

   V<V<int>> sum(n+1, V<int>(K+2));

   dp[0][0] = 1;

   for (int k = 0; k <= K; k++) {

      sum[0][k+1] = sum[0][k] + dp[0][k];

   }

   for (int i = 0; i < n; i++) {

      for (int k = 0; k <= K; k++) {

         dp[i+1][k] = (((sum[i][k+1] - sum[i][max(k-a[i], 0LL)]) % MOD) + MOD) % MOD;

         sum[i+1][k+1] = (sum[i+1][k] + dp[i+1][k]) % MOD;

      }

   }

   cout << dp[n][K] << endl;



   return 0;

}


// Fastest known solution for this problem: