#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t = 1;
  while (t--) {
    long long n, s;
    cin >> n >> s;
    vector<long long> a(n);
    for (auto &x : a) cin >> x;
    vector<unordered_map<long long, long long>> d(n + 1);
    unordered_map<long long, unordered_map<long long, long long>> f;
    d[n - 1][a[n - 1]] = 1;
    f[a[n - 1]][n - 1]++;
    long long ans = 0;
    if (a[n - 1] == s) ans += n;
    for (long long i = n - 2; i >= 0; i--) {
      d[i][a[i]] = 1;
      if (a[i] == s) {
        ans += (i + 1) * (n - i);
      }
      for (long long k = s; k >= 1; k--) {
        if (d[i + 1][k]) {
          d[i][k] += d[i + 1][k];
          d[i][a[i] + k] += d[i + 1][k];
          for (auto &p : f[k]) {
            long long j = p.first;
            if (a[i] + k == s) {
              ans += f[k][j] * (i + 1) * (n - j);
            }
          }
        }
      }
      for (long long k = s; k >= 1; k--) {
        if (d[i + 1][k]) {
          for (auto &p : f[k]) {
            long long j = p.first;
            if (a[i] + k <= s) {
              f[a[i] + k][j] += f[k][j];
            }
          }
        }
      }
      f[a[i]][i]++;
    }
    printf("%lld\n", ans);
  }
}
