#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T& a, T b) {
  a = min(a, b);
}
template <class T>
void chmax(T& a, T b) {
  a = max(a, b);
}
constexpr int INF = 1 << 30;
constexpr long long INFL = 1LL << 60;
constexpr long long MOD = 1000000007;
constexpr long double EPS = 1e-12;
long double PI = acos(-1.0);
struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
void solve() {
  long long n, s;
  cin >> n >> s;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<vector<vector<mint> > > dp(
      n + 1, vector<vector<mint> >(s + 1, vector<mint>(2)));
  for (long long i = 0; i < n; i++) {
    dp[i + 1][0][0] += 1;
    if (a[i] <= s) dp[i + 1][a[i]][0] += 1;
    for (long long j = 0; j <= s; j++) {
      dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1];
      dp[i + 1][j][0] += dp[i][j][0];
      if (a[i] + j <= s) dp[i + 1][a[i] + j][0] += dp[i][j][0];
    }
  }
  cout << dp[n][s][0].x + dp[n][s][1].x << endl;
  return;
}
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  solve();
}
