#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long mod = 998244353;
int inf = 1000001000;
long long INF = 1e18 + 5;
int main() {
  long long n, s;
  cin >> n >> s;
  vector<long long> a(n);
  for (long long(i) = 0; (i) < (n); (i)++) cin >> a[i];
  vector<vector<long long>> d(n + 1, vector<long long>(5000, 0));
  for (long long(i) = 0; (i) < (n); (i)++) {
    d[i][0] = i + 1;
  }
  long long ans = 0;
  for (long long(i) = 0; (i) < (n); (i)++) {
    for (long long(j) = 0; (j) < (s); (j)++) {
      if (j != 0) d[i + 1][j] = (d[i + 1][j] + d[i][j]) % MOD;
      if (j + a[i] == s) {
        ans = (ans + d[i][j] * (n - i)) % MOD;
      }
      if (j + a[i] < s) {
        d[i + 1][j + a[i]] = (d[i + 1][j + a[i]] + d[i][j]) % MOD;
      }
    }
  }
  cout << ans << endl;
}
