// Standard Stuff
#include <bits/stdc++.h>
using namespace std;

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

// 0-indexed
template<typename T>
class FenwickTree {
	private:

		const int n;
		vector<T> bits;
		const int log_val;

	public:

		FenwickTree(int N) : n(N), bits(N+1, 0), log_val(__lg(N)) {}

		FenwickTree(vector<T>& arr) : FenwickTree(arr.size()) {
			for(int i = 0; i < n; ++i)
				add(i, arr[i]);
		}

		void add(int idx, T delta){
			for (++idx; idx <= n; idx += (idx & -idx))
				bits[idx] += delta;
		}

		T sum(int r){
			T ret = 0;
			for (++r; r > 0; r -= (r & -r))
				ret += bits[r];
			return ret;
		}

		T sum(int l, int r){
			return sum(r) - sum(l - 1);
		}

		int find_kth_by_order(T val){
			/*
			 * Returns lowest i st sum(0,i) >= val.
			 * Note that if no such value exists, it returns n, which is outside the legal positions of the array.
			 */

			int pos = 0;

			for(int i = log_val; i >= 0; --i){
				int next_pos = pos + (1 << i);

				if(next_pos <= n and bits[next_pos] < val){
					pos = next_pos;
					val -= bits[next_pos];
				}
			}

			return pos;
		}

		friend ostream& operator << (ostream& os, FenwickTree<T>& ft){
			os << "N:" << ft.n << " ==> " << ft.bits;
			return os; 
		}
};

void solve(){
	int n; ll k;
	cin >> n >> k;

	vector<int> arr(n);
	for(auto& i: arr) cin >> i;

	// count of (i,j) st \Sigma_{k = arr[i..j]} / (j - i + 1) >= k
	//                st presum(j) - presum(i - 1) >= k * j - k * (i - 1)
	//                st presum(j) - k * j >= presum(i - 1) - k * (i - 1)

	vector<ll> vec(1, 0);
	for(auto i: arr) vec.push_back(i + vec.back());
	for(int i = 0; i <= n; ++i) vec[i] -= k * i;

	// ans = count inversions in vec !

	ll cou = 0;

	// COMPRESS
	// sort
	set<ll> s(vec.begin(), vec.end());
	//find ordering
	map<ll,int> m;
	int no = 0; for(auto element: s) m[element] = no++;
	// transform vec
	for(auto& i: vec) i = m[i];

	FenwickTree<int> fen{no};
	fen.add(vec.front(), 1);

	for(int i = 1; i <= n; ++i){
		cou += fen.sum(vec[i]);
		fen.add(vec[i], 1);
	}

	cout << cou << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 28276