#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  int i, j, k;
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<vector<int>>> dp(n + 1,
                                 vector<vector<int>>(s + 1, vector<int>(3, 0)));
  dp[0][0][0] = 1;
  for (i = 1; i <= n; i++) {
    for (j = 0; j <= s; j++) {
      for (k = 0; k < 3; k++) {
        dp[i][j][k] = dp[i - 1][j][k];
      }
      dp[i][j][1] += dp[i - 1][j][0];
      dp[i][j][2] += (dp[i - 1][j][0] + dp[i - 1][j][1]);
      if (j - a[i - 1] >= 0)
        dp[i][j][1] += dp[i - 1][j - a[i - 1]][0] + dp[i - 1][j - a[i - 1]][1];
      if (j - a[i - 1] >= 0)
        dp[i][j][2] += dp[i - 1][j - a[i - 1]][0] + dp[i - 1][j - a[i - 1]][1];
    }
  }
  cout << dp[n][s][2] << endl;
}
