#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////
template <class T>
struct Compress {
    vector<T> v;
    bool ok = false;
    void add(T const& x) { v.push_back(x); }
    template <class It>
    void add(It f, It l) { copy(f,l,back_inserter(v)); }
    void init() { sort(all(v)); v.erase(unique(all(v)), v.end()); ok = true; }
    int size() const { return v.size(); }
    T operator[](int i) const { assert(ok); return v[i]; }
    int find(T const& x) const { assert(ok); return lower_bound(all(v),x)-v.begin(); }
};

template <class Handler>
struct Segtree : Handler {
    using Value = typename Handler::Value;
    using Handler::unit; // () -> Value
    using Handler::merge; // (Value,Value) -> Value

    vector<Value> v; // use v[1..size-1]
    int size; // power of 2

    Segtree() : v(), size(0) {}
    Segtree(int n, Value const& x = unit()) { init(n,x); }
    template <class It> Segtree(It first, It last) { init(first, last); }
    void init(int n, Value const& x = unit()) {
        assert(n >= 0);
        for (size = 1; size < n; size <<= 1) ;;
		v.assign(2*size, x);
    }
    template <class It> void init(It first, It last) {
        init(distance(first,last));
        copy(first, last, next(v.begin(), size));
        for (int i = size-1; i >= 1; i--) v[i] = merge(v[2*i],v[2*i+1]);
    }
    void set(int i, Value const& x) {
        assert(0 <= i && i < size);
        i += size; v[i] = x;
        while (i > 1) i >>= 1, v[i] = merge(v[2*i],v[2*i+1]);
    }
    Value operator[](int i) const {
        assert(0 <= i && i < size);
        return v[size + i];
    }
    // [l,r)
    Value fold(int l, int r) const {
        assert(0 <= l && l <= r && r <= size);
        Value x = unit(), y = unit();
        for (l += size, r += size; l < r; l >>= 1, r >>= 1) {
            if (l&1) x = merge(x, v[l++]);
            if (r&1) y = merge(v[--r], y);
        }
        return merge(x,y);
    }
};

struct RangeSum {
    using Value = int;
    constexpr static Value unit() { return 0; }
    constexpr static Value merge(Value x, Value y) { return x+y; }
};

int32_t main() {
    int n,k; cin >> n >> k;
    vector<int> a(n); cin >> a;
    rep (i,n) a[i] -= k;
    vector<int> s(n+1);
    rep1 (i,n) s[i] = s[i-1]+a[i-1];

    Compress<int> X;
    X.add(all(s)); X.init();
    for (int &x : s) x = X.find(x);

    // BIT bit(X.size());
    // int sum = 0;
    // bit.add(s[0],1);
    // rep1 (i,n) {
    //     sum += bit.sum(s[i]+1);
    //     bit.add(s[i],1);
    // }
    Segtree<RangeSum> seg(X.size());
    int sum = 0;
    seg.set(s[0],1);
    rep1 (i,n) {
        sum += seg.fold(0,s[i]+1);
        seg.set(s[i],seg[s[i]]+1);
    }
    cout << sum << endl;
}


Measured memory_bytes: 9200