// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>

#include<stack>

#include<string>

#include<cmath>

#include<algorithm>

#include<bitset>

#include<map>

#include<unordered_map>

#include<functional>

#include<set>

#include<numeric>

 

#pragma region

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)

#define rep(i,n) FOR(i,0LL,n)

#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)

#define rrep(i,n) RFOR(i,0LL,n)

#define all(x) x.begin(),x.end()

#define rall(x) x.rbegin(),x.rend()

#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)

#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())

#define SUM(a) accumulate(all(a),0LL)

#define pb push_back

#define endl '\n'

typedef long long int ll;

typedef vector<ll> vll;

typedef vector<vll> vvll;

typedef pair<ll, ll> pll;

typedef vector<pll> vpll;

typedef vector<string> vs;

typedef map<ll, ll> MAP;

const ll inf = 2222222222222222222LL;

const ll mod = 1000000007LL;

 

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;

string s;

bool ok = true, flag = false;

ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };

ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };

#pragma endregion

#define MAX 222222

 

 

struct BinaryIndexed {

	ll num;

	vll bit;

 

	BinaryIndexed(ll x = MAX) {

		num = x;

		bit.resize(x + 1, 0);

	}

 

	ll sum(ll i) {

		ll ret = 0;

		while (i > 0) {

			ret += bit[i];

			i -= i & -i;

		}

		return ret;

	}

 

	void add(ll i, ll x) {

		if (i == 0) cout << "access 0 index" << endl;

		while (i <= num) {

			bit[i] += x;

			i += i & -i;

		}

	}

};

 

ll a[MAX], b[MAX];

 

int main(void) {

	ios::sync_with_stdio(false);

	cin.tie(0);

 

 

	cin >> n >> m;

	FOR(i, 1, n + 1) {

		cin >> a[i];

	}

	FOR(i, 1, n + 1) b[i] = b[i - 1] + a[i];

	FOR(i, 1, n + 1) b[i] = i * m - b[i];

	vll v;

	FOR(i, 1, n + 1) v.pb(b[i]);

	sort(all(v));

	MAP comp;

	rep(i, n) comp[v[i]] = i + 1;

	BinaryIndexed bit;

	FOR(i, 1, n + 1) {

		if (comp[b[i]] > 1) ans += (i - 1) - bit.sum(comp[b[i]] - 1);

		else ans += i - 1;

		if (b[i] <= 0) ans++;

		bit.add(comp[b[i]], 1);

	}

	cout << ans << endl;

 

 

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.8608743388262043x):
#include <algorithm>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <map>

#include <set>

#include <vector>

#define rr int

using namespace std;

typedef long long ll;

ll read() {

    char i = getchar();

    ll f = 1, res = 0;

    while (i < '0' || i > '9') {

        if (i == '-') f = -1;

        i = getchar();

    }

    while (i >= '0' && i <= '9') {

        res = res * 10 + i - '0';

        i = getchar();

    }

    return f * res;

}

int n;

ll K;

const int N = 3e5 + 50;

ll a[N];

ll sum[N], c[N];

ll ans = 0;

inline void merge(int l, int r) {

    if (l < r) {

        int mid = (l + r) >> 1;

        merge(l, mid);

        merge(mid + 1, r);

        int i = l, j = mid + 1, now = l;

        while (i <= mid && j <= r) {

            if (a[i] <= a[j]) {

                c[now++] = a[i++];

                ans += r - j + 1; //这里注意不能重复计算，每次取得取单独更新贡献

            } else

                c[now++] = a[j++];

        }

        while (i <= mid) c[now++] = a[i++];

        while (j <= r) c[now++] = a[j++];

        for (rr i = l; i <= r; ++i) a[i] = c[i];

    }

}

int main() {

    n = read() + 1, K = read();

    for (rr i = 2; i <= n; ++i) {

        a[i] = read();

        sum[i] = sum[i - 1] + a[i];

        a[i] = sum[i] - K * ll(i - 1);

    }

    // for (rr i = 1; i <= n; ++i) cout << a[i] << ' ';

    merge(1, n);

    // for (rr i = 1; i <= n; ++i) cout << a[i] << endl;

    cout << ans;

}