#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
int main() {
  int N, S;
  cin >> N >> S;
  vector<int> A(N);
  for (ll i = 0; i < (ll)(N); i++) cin >> A[i];
  vector<vector<int>> dp(N + 1, vector<int>(S + 1, 0));
  for (ll r = 0; r < (ll)(N); r++) {
    for (ll s = 0; s < (ll)(S + 1); s++) {
      dp[r + 1][s] = dp[r][s];
      if (s >= A[r]) dp[r + 1][s] += dp[r][s - A[r]];
      if (s == 0 || s == A[r]) dp[r + 1][s]++;
    }
  }
  ll res = 0;
  for (ll r = 1; r <= (ll)(N); r++) {
    res += dp[r][S];
    res %= 1000000007;
  }
  cout << res << endl;
}
