#include <bits/stdc++.h>
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, size_t N, class T>
void Fill(A (&a)[N], const T &v) {
  fill((T *)a, (T *)(a + N), v);
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &t) {
  os << "{";
  for (int i = 0; i < (t.size()); i++) {
    os << t[i] << ",";
  }
  os << "}";
  return os;
}
template <class T, size_t n>
ostream &operator<<(ostream &os, const array<T, n> &t) {
  os << "{";
  for (int i = 0; i < (n); i++) {
    os << t[i] << ",";
  }
  os << "}";
  return os;
}
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &t) {
  return os << "(" << t.first << "," << t.second << ")";
}
const long long int INF = 1e9 + 7;
long long int dp[3005][9005] = {};
int main() {
  ios_base::sync_with_stdio(false);
  long long int N, S, ans = 0;
  long long int A[3005];
  cin >> N >> S;
  for (int i = 0; i < (N); i++) cin >> A[i];
  for (int i = 0; i < (N); i++) {
    dp[i + 1][A[i]] += i + 1;
    for (int j = 0; j < (3005); j++) dp[i + 1][j] += dp[i][j];
    for (int j = 0; j < (3005); j++) dp[i + 1][j + A[i]] += dp[i][j];
    if (S > A[i]) ans += dp[i][S - A[i]] * (N - i);
    if (S == A[i]) ans += (i + 1) * (N - i);
  }
  cout << ans << endl;
  return 0;
}
