#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = 998244353;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (long long)1e9 + 7;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct Edge {
  int to, cap, rev;
  Edge(int _to, int _cap, int _rev) {
    to = _to;
    cap = _cap;
    rev = _rev;
  }
};
void add_edge(vector<vector<Edge>>& G, int from, int to, int cap, bool revFlag,
              int revCap) {
  G[from].push_back(Edge(to, cap, G[to].size()));
  if (revFlag) G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}
void solve() {
  long long n, s;
  cin >> n >> s;
  vector<long long> a(n);
  for (int(i) = (int)(0); (i) < (int)(n); (i)++) cin >> a[i];
  vector<vector<long long>> dp(n + 1, vector<long long>(s + 1, 0));
  dp[0][0] = 1;
  long long ans = 0;
  for (int(i) = (int)(0); (i) < (int)(n); (i)++) {
    if (a[i] <= s)
      (dp[i + 1][a[i]] += i + 1) %= MOD;
    else if (a[i] == s)
      (dp[i + 1][a[i]] += (i + 1) * (n - i) % MOD) %= MOD;
    dp[i + 1][0] = 1;
    for (int(j) = (int)(1); (j) < (int)(s + 1); (j)++) {
      if (dp[i][j] == 0) continue;
      if (j + a[i] < s)
        (dp[i + 1][j + a[i]] += dp[i][j]) %= MOD;
      else if (j + a[i] == s)
        (dp[i + 1][j + a[i]] += dp[i][j] * (n - i) % MOD) %= MOD;
      (dp[i + 1][j] += dp[i][j]) %= MOD;
    }
  }
  cout << dp[n][s] << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
