#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
void INIT() {
  ios::sync_with_stdio(false);
  cin.tie(0);
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll fpow(ll b, ll p) {
  b %= (ll)(1e9 + 7);
  ll ans = 1;
  while (p > 0) {
    if (p & 1) ans = (ans * b) % (ll)(1e9 + 7);
    p /= 2;
    b = (b * b) % (ll)(1e9 + 7);
  }
  return ans;
}
int dp[3050];
int32_t main() {
  INIT();
  int n, s;
  cin >> n >> s;
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  int ans = 0;
  for (int i = n; i >= 1; i--) {
    int t;
    cin >> t;
    if (t <= s) ans += i * dp[s - t];
    for (int j = s - 1; j > t; j--) {
      if (j - t >= 0) dp[j] += dp[j - t];
    }
    if (t < s) dp[t] += n - i + 1;
    dp[0]++;
  }
  cout << ans << "\n";
  return 0;
}
