#include <bits/stdc++.h>
template <class T>
inline T chmax(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T>
inline T chmin(T& a, const T b) {
  return a = (a > b) ? b : a;
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = acos(-1);
using namespace std;
struct INIT {
  INIT() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  }
} INIT;
signed main() {
  ll N, S;
  cin >> N >> S;
  vector<ll> A(N);
  for (ll i = 0; i < ll(N); ++i) cin >> A[i];
  ll dp[N + 1][S + 1][3];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (ll i = 0; i < ll(N); ++i)
    for (ll j = 0; j < ll(S + 1); ++j) {
      (dp[i + 1][j][0] += dp[i][j][0]) %= MOD;
      (dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1]) %= MOD;
      (dp[i + 1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= MOD;
      if (j + A[i] <= S) {
        (dp[i + 1][j + A[i]][1] += dp[i][j][0] + dp[i][j][1]) %= MOD;
        (dp[i + 1][j + A[i]][2] += dp[i][j][0] + dp[i][j][1]) %= MOD;
      }
    }
  cout << dp[N][S][2] << "\n";
  return 0;
}
