#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long N = 3e3 + 1;
const long long S = 3e3 + 1;
long long dp[N][S];
long long a[N];
long long n, s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  memset(dp, 0, sizeof(dp));
  cin >> n >> s;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    dp[i][a[i]] += i;
    for (long long j = 0; j < N; j++) {
      dp[i][j] += dp[i - 1][j];
      if (j + a[i] < N) {
        dp[i][j + a[i]] += dp[i - 1][j];
      }
    }
    ans += (dp[i][s] - dp[i - 1][s]) * (n - i + 1);
  }
  cout << ans << '\n';
  return 0;
}
