#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 2;
const int INF = 2e18;

signed main() {
    int N, S;
    cin >> N >> S;
    vector<int> A(N + 1, 0);
    for (int i = 1; i <= N; i++) cin >> A[i];
    vector<int> dp(S + 1, 0), count(N + 1, 0);
    dp[0] = 1;
    map<int, int> end;
    for (int i = 1; i <= N; i++) {
        int base = A[i];
        map<int, int> temp = end;
        end = map<int, int>();
        for (auto itr = temp.begin(); itr != temp.end(); itr++) {
            end[itr->first + base] = itr->second;
        }
        for (int i = 0; i < S; i++) {
            if (i + base < S) dp[i + base] += dp[i];
            else if (dp[i] > 0) end[i + base] += dp[i];
        }

        count[i] = dp[S];
    }
    int sum = accumulate(A.begin(), A.end(), 0LL);
    vector<int> cc(N + 1, 0);
    for (int i = 1; i <= N; i++) cc[i] = cc[i - 1] + A[i];
    vector<int> ans;
    ans.push_back(0);
    for (auto itr = end.begin(); itr != end.end(); itr++) {
        ans.push_back(itr->second);
        *ans.rbegin() += *next(ans.rbegin(), 1);
    }

    int res = 0;
    for (int L = 1; L <= N; L++) {
        for (int R = L; R <= N; R++) {
            int minus = cc[R] - cc[L - 1];
            int dist = distance(end.begin(), end.lower_bound(sum - minus));
            res += ans[ans.size() - 1] - ans[dist - 1];
            // ans += count[R] - count[L - 1];
        }
    }
    cout << res << endl;
}
