#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  std::cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
signed main() {
  ios_base::sync_with_stdio(0);
  long long TESTS = 1;
  while (TESTS--) {
    long long n, s;
    cin >> n >> s;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    vector<long long> dp[s];
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
      for (long long j = s - a[i]; j >= 1; j--) {
        for (auto k : dp[j]) {
          if (j + a[i] < s)
            dp[j + a[i]].push_back(k);
          else if (j + a[i] == s) {
            ans += (n - i) * (k);
          }
        }
      }
      if (a[i] < s)
        dp[a[i]].push_back(i + 1);
      else if (a[i] == s) {
        ans += (n - i) * (i + 1);
      }
    }
    cout << ans;
  }
}
