#include <bits/stdc++.h>
using namespace std;
const long long N = 3000, M = 3000;
long long n, m;
long long a[N + 1];
long long dp[M + 1];
signed main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (m == a[i])
      ans += i * (n - i + 1);
    else if (m > a[i])
      ans += dp[m - a[i]] * (n - i + 1);
    for (long long j = m; j >= a[i]; j--)
      dp[j] += dp[j - a[i]] + (j == a[i] ? i : 0);
  }
  cout << ans;
  return 0;
}
