#include <bits/stdc++.h>
using namespace std;
using Edge = pair<long long, long long>;
using Graph = vector<vector<int>>;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  int N, S, A[3030];
  cin >> N >> S;
  long long dp[3030];
  dp[0] = 0;
  long long ret = 0;
  for (int i = (0); i < (N); ++i) {
    cin >> A[i];
    for (int j = S - A[i]; j >= 0; j--) {
      if (j == 0)
        (dp[A[i]] += i + 1) %= 1000000007;
      else
        (dp[A[i] + j] += dp[j]) %= 1000000007;
    }
    ret += dp[S];
  }
  cout << ret % 1000000007 << '\n';
}
