#include <bits/stdc++.h>
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
  std::cout << a << ' ';
  err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &...args) {
  for (auto &v : arg) std::cout << v << ' ';
  err(args...);
}
using namespace std;
const int N = 3000 + 5;
int n, s;
int a[N];
int dp[N][N], sum[N];
void run() {
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    dp[i][a[i]] = i;
    for (int j = a[i]; j <= s; j++) {
      dp[i][j] += sum[j - a[i]];
    }
    for (int j = 0; j <= s; j++) {
      sum[j] += dp[i][j];
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += 1ll * dp[i][s] * (n - i + 1);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  run();
  return 0;
}
