#include <bits/stdc++.h>

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

template <typename Base>
class BinaryIndexedTree
{
public:
    using T = typename Base::T;
    using AbelGroup = Base;

    BinaryIndexedTree(const int n) : data_num(n), size(1 << (__lg(2 * data_num - 1))), value(size + 1, AbelGroup::identity()) { assert(n > 0); }
    BinaryIndexedTree(const vector<T>& val) : data_num(val.size()), size(1 << (__lg(2 * data_num - 1))), value(size + 1, AbelGroup::identity())
    {
        for (int i = 1; i <= size; i++) {
            value[i] = val[i - 1];
        }
        for (int x = 1; x < size; x++) {
            value[x + (x & -x)] += value[x];
        }
    }

    T accumulate(const int a) const
    {
        assert(0 <= a and a < data_num);
        int ind = a + 1;
        T sum = AbelGroup::identity();
        while (ind > 0) {
            sum = op(sum, value[ind]);
            ind &= ind - 1;
        }
        return sum;
    }

    void add(const int a, const T& val)
    {
        assert(0 <= a and a < data_num);
        int ind = a + 1;
        while (ind <= size) {
            value[ind] = op(value[ind], val);
            ind += ind & (-ind);
        }
    }

    T get(const int a) const
    {
        assert(0 <= a and a < data_num);
        if (a == 0) {
            return accumulate(a);
        } else {
            return op(op.inv(accumulate(a - 1)), accumulate(a));
        }
    }

    void print() const
    {
        show(value);
    }

private:
    const int data_num;
    const int size;
    const AbelGroup op{};
    vector<T> value;
};

struct Sum {
    using T = ll;
    T operator()(const T& a, const T& b) const
    {
        return a + b;
    }
    T inv(const T& a) const
    {
        return -a;
    }
    static constexpr T identity()
    {
        return 0;
    }
};

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> s(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        if (i == 0) {
            s[i] = a[i];
        } else {
            s[i] = s[i - 1] + a[i];
        }
    }
    vector<ll> t(n);
    for (ll i = 0; i < n; i++) {
        t[i] = s[i] - (i + 1) * k;
    }
    ll un = 0;
    for (ll i = 0; i < n; i++) {
        if (t[i] >= 0) {
            un++;
        }
    }
    //    show(t);

    map<ll, ll> zip;
    vector<ll> t_copy = t;
    sort(t_copy.begin(), t_copy.end());
    t_copy.erase(unique(t_copy.begin(), t_copy.end()), t_copy.end());
    for (ll i = 0; i < t_copy.size(); i++) {
        zip[t_copy[i]] = i;
    }
    for (ll i = 0; i < n; i++) {
        t[i] = zip[t[i]];
    }

    //    show(t);
    BinaryIndexedTree<Sum> bit(n);
    ll sum = 0;
    for (ll i = 0; i < n; i++) {
        //        bit.print();
        sum += bit.accumulate(t[i]);
        bit.add(t[i], 1);
    }
    //    bit.print();
    cout << sum + un << endl;
    return 0;
}


Measured memory_bytes: 20992