#include <bits/stdc++.h>
using namespace std;
template <class T = int>
using V = vector<T>;
template <class T = int>
using VV = V<V<T> >;
template <class T = int>
void print(vector<T> v) {
  for (auto a : v) cout << a << " ";
  cout << endl;
}
long long n, s, a[3010], ans = 0;
long long dp[3010][6010][3];
long long mod = 998244353;
int main(void) {
  cin >> n >> s;
  for (long long i = ((long long)(1)); i <= ((long long)(n)); i++) cin >> a[i];
  for (long long i = 0; i < ((long long)(n + 1)); i++)
    for (long long j = 0; j < ((long long)(s + 1)); j++)
      for (long long k = 0; k < ((long long)(3)); k++) dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  for (long long i = ((long long)(1)); i <= ((long long)(n)); i++) {
    dp[i][0][0] += dp[i - 1][0][0];
    dp[i][0][1] += dp[i - 1][0][0];
    dp[i][a[i]][1] += dp[i - 1][0][0];
    dp[i][0][2] += dp[i - 1][0][0];
    dp[i][a[i]][2] += dp[i - 1][0][0];
    for (long long j = 0; j < ((long long)(s + 1)); j++) {
      dp[i][j][1] += dp[i - 1][j][1];
      dp[i][j + a[i]][1] += dp[i - 1][j][1];
      dp[i][j][2] += dp[i - 1][j][1];
      dp[i][j + a[i]][2] += dp[i - 1][j][1];
      dp[i][j][2] += dp[i - 1][j][2];
    }
  }
  cout << dp[n][s][2] << endl;
  return 0;
}
