#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
const long long INF =
    sizeof(long long) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const long long MOD = (long long)1e9 + 7;
const double EPS = 1e-9;
long long DP[3010];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, S;
  cin >> N >> S;
  vector<long long> A(N);
  for (long long i = (0), i_len = (N); i < i_len; i++) cin >> A[i];
  long long ans = 0;
  for (long long i = (0), i_len = (N); i < i_len; i++) {
    if (A[i] > S) continue;
    ans += DP[S - A[i]] * (N - i);
    if (A[i] == S) ans += (i + 1) * (N - i);
    ans %= MOD;
    for (long long j = (S)-1; j >= (0); j--) {
      if (j + A[i] <= S) {
        DP[j + A[i]] += DP[j];
        DP[j + A[i]] %= MOD;
      }
    }
    DP[A[i]] += i + 1;
    DP[A[i]] %= MOD;
  }
  cout << ans << endl;
  return 0;
}
