#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
long long dp[3001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, s;
  long long res = 0;
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (x > s) continue;
    if (x == s) {
      res += 1ll * i * (n - i + 1);
    } else {
      res += dp[s - x] * (n - i + 1);
      for (int j = s; j > x; j--) dp[j] += dp[j - x];
      dp[x] += i;
    }
  }
  cout << res;
  return 0;
}
