#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000001
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 1000001;
const ll M = 1;

struct point {
    ll x, y;
};

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    else if(n & 1)
        return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll tmp = fast_exp(x, n >> 1);
        return tmp * tmp % mod;
    }
}

bool c(string s)
{
    ll n = s.size();
    for(int i = 0; i < n / 2; i++)
    {
        if(s[i] != s[n - i - 1]) return false;
    }
    return true;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, ans = 0, x, y, k, s;
        cin >> n >> s;
        ll a[n];
        m = 1000 * n + 1;
        ll dp[n][m] = {};
        for(int i = 0; i < n; i++) cin >> a[i];
        dp[n - 1][0] = 1;
        dp[n - 1][a[n - 1]] = 1;
        ans = dp[n - 1][s];
        for(int i = n - 2; i > -1; i--)
        {
            for(int j = 1; j < m - a[i]; j++)
            {
                dp[i][j + a[i]] += dp[i + 1][j];
            }
            for(int j = 0; j < m; j++)
            dp[i][j] += dp[i + 1][j];
            dp[i][a[i]] += n - i;
            ans += dp[i][s];
        }
        cout << ans << "\n";
    }
    return 0;
}
