// Author: raghav_0901
#include<bits/stdc++.h>
#define int long long int
#define f(i,s,e) for(i=s;i<e;++i)
#define fr(i,s,e) for(i=s;i>=e;i--)
#define ff(i,s,e,f) for(i=s;i<e && f;++i)
#define mem(arr,val) memset(arr, val, sizeof(arr))
#define mems(arr, val, n) memset(arr, val, n)
#define vec vector<int>
#define pr pair<int,int>
#define lim 1000000
#define mod 1000000007
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

vec v;
vector<vec> dp[3000][3001];
vector<vec> solve(int n,int s,int pos=0)
{
    if(s==0)
    {
        vector<vec> x;
        x.push_back(vec ());
        return x;
    }
    if(dp[pos][s].size())
        return dp[pos][s];
    if( pos==n)
        return vector<vec> ();
    vector<vec> arr = solve(n,s,pos+1);
    vector<vec> arr2 = solve(n,s-v[pos],pos+1);
    for(auto &it:arr2)
    {
        if(it.size()<2)
            it.push_back(pos);
        else
            it[1]=pos;
        arr.push_back(it);
    }
    return dp[pos][s]=arr;
}

signed main()
{
    Arena
    register int i,j,num,t=1;
    //cin>>t;
    while(t--)
    {
        register int n,s;cin>>n>>s;
        v.resize(n);
        for(register int &x:v)
            cin>>x;
        vector<vec> arr = solve(n,s);
        int ans=0;
        for(auto x:arr)
        {
            ans+=(x.back()-0+1)*(n-x.front());
        }
        cout<<ans<<endl;
    }
    return 0;
}