#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  int dp[2][s + 1];
  memset(dp, 0, sizeof(dp));
  int x;
  cin >> x;
  dp[0][x] = 1;
  long long ans = 0;
  if (x == s) ans += n;
  for (int i = 1; i < n; i++) {
    cin >> x;
    for (int j = 0; j < x; j++) dp[1][j] = dp[0][j];
    for (int j = x; j < s + 1; j++) dp[1][j] = dp[0][j - x] + dp[0][j];
    if (x > s) continue;
    dp[1][x] += i + 1;
    if (x == s) ans += n;
    ans += dp[0][s - x] * (n - i);
    for (int j = 0; j < s + 1; j++) {
      dp[0][j] = dp[1][j];
      dp[1][j] = 0;
    }
  }
  cout << ans;
  return 0;
}
