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

#define rep(i,n) for (int i = 0; i < (n); ++i)

#define chmax(a, b) a = max(a, b);

#define chmin(a, b) a = min(a, b);

using namespace std;

using ll = long long;

using P = pair<int,int>;



#define MOD 1000000007

//#define MOD 998244353

struct mint {

	int i;

	mint() : i(0) {}

	mint(int x) {

		i = int(x % MOD);

		if (i < 0) i += MOD;

	}

	template<class T> mint(T x) {

		i = int(x % MOD);

		if (i < 0) i += MOD;

	}

	mint operator+(const mint x) const {return i + x.i;}

	mint operator-(const mint x) const {return i - x.i;}

	mint operator*(const mint x) const {return (long long)i * x.i;}

	mint operator/(const mint x) const {return (long long)i * x.pow(MOD - 2).i;}

	mint inv() {return pow(MOD - 2);}

	template<class T> mint pow(T p) const {

		long long r = 1;

		long long t = i;

		for(; p > 0; p >>= 1) {

			if (p & 1) r = r * t % MOD;

			t = t * t % MOD;

		}

		return r;

	}

	template<class T1, class T2> static mint pow(T1 a, T2 b) {

		long long r = 1;

		long long t = (long long)(a % MOD);

		for(; b > 0; b >>= 1) {

			if (b & 1) r = r * t % MOD;

			t = t * t % MOD;

		}

		return r;

	}

	mint& operator+=(const mint x) {

		i = (i + x.i) % MOD;

		return *this;

	}

	mint& operator-=(const mint x) {

		i = i - x.i;

		if (i < 0) i += MOD;

		return *this;

	}

	mint& operator*=(const mint x) {

		i = (int)((long long)i * x.i % MOD);

		return *this;

	}

	mint& operator/=(const mint x) {

		i = (long long)i * x.pow(MOD - 2).i % MOD;

		return *this;

	}

};



std::ostream& operator<<(std::ostream& os, const mint& m) {

	return os << m.i;

}







template<typename T>

struct BIT {

  int n;

  vector<T> d;

  BIT(int n=0):n(n),d(n+1) {}

  void add(int i, T x=1) {

    for (i++; i <= n; i += i&-i) {

      d[i] += x;

    }

  }

  T sum(int i) {

    T x = 0;

    for (i++; i; i -= i&-i) {

      x += d[i];

    }

    return x;

  }

  T sum(int l, int r) {

    return sum(r-1) - sum(l-1);

  }

};





int main() {

    int n, k;

    cin >> n >> k;

    BIT<mint> dp(k+1);

    dp.add(0, 1);

    rep(_, n) {

        int a;

        cin >> a;

        BIT<mint> ndp(k+1);

        rep(i, k+1) {

            int lb = max(0, i-a);

            ndp.add(i, dp.sum(lb, i+1));

        }

        swap(dp, ndp);

    }

    cout << dp.sum(k, k+1) << endl;

}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)

#define chmax(a, b) a = max(a, b);

#define chmin(a, b) a = min(a, b);

using namespace std;

using ll = long long;

using P = pair<int,int>;



#define MOD 1000000007

//#define MOD 998244353

struct mint {

	int i;

	mint() : i(0) {}

	mint(int x) {

		i = int(x % MOD);

		if (i < 0) i += MOD;

	}

	template<class T> mint(T x) {

		i = int(x % MOD);

		if (i < 0) i += MOD;

	}

	mint operator+(const mint x) const {return i + x.i;}

	mint operator-(const mint x) const {return i - x.i;}

	mint operator*(const mint x) const {return (long long)i * x.i;}

	mint operator/(const mint x) const {return (long long)i * x.pow(MOD - 2).i;}

	mint inv() {return pow(MOD - 2);}

	template<class T> mint pow(T p) const {

		long long r = 1;

		long long t = i;

		for(; p > 0; p >>= 1) {

			if (p & 1) r = r * t % MOD;

			t = t * t % MOD;

		}

		return r;

	}

	template<class T1, class T2> static mint pow(T1 a, T2 b) {

		long long r = 1;

		long long t = (long long)(a % MOD);

		for(; b > 0; b >>= 1) {

			if (b & 1) r = r * t % MOD;

			t = t * t % MOD;

		}

		return r;

	}

	mint& operator+=(const mint x) {

		i = (i + x.i) % MOD;

		return *this;

	}

	mint& operator-=(const mint x) {

		i = i - x.i;

		if (i < 0) i += MOD;

		return *this;

	}

	mint& operator*=(const mint x) {

		i = (int)((long long)i * x.i % MOD);

		return *this;

	}

	mint& operator/=(const mint x) {

		i = (long long)i * x.pow(MOD - 2).i % MOD;

		return *this;

	}

};



std::ostream& operator<<(std::ostream& os, const mint& m) {

	return os << m.i;

}



int main() {

    int n, k;

    cin >> n >> k;

    vector<mint> dp(k+2);

    dp[0] = 1;

    rep(_, n) {

        int a;

        cin >> a;

        vector<mint> ndp(k+2);

        rep(i, k+1) {

            int ub = min(k+1, i+a+1);

			ndp[i] += dp[i];

			ndp[ub] -= dp[i];

        }

		for(int i = 1; i <= k; i++) {

			ndp[i] += ndp[i-1];

		}

        swap(dp, ndp);

    }

    cout << dp[k] << endl;

}


// Fastest known solution for this problem: