#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

template < template < typename ... > class Container, typename T >
auto coenumerate(Container< T > const& v) {
  auto n = v.size();
  Container< std::pair< T, int >> ret(n);
  for (std::size_t i = 0; i < n; i++)
    { ret.at(i) = {v.at(i), i}; }
  return ret;
}

template < typename Value, typename BinaryOp >
class segment_tree {
    int                  sz, n, N;
    BinaryOp             op;
    Value                id;
    std::vector< Value > table;

    auto& op_eq(Value& x, Value y) const
      { return x = op(x, y); }
    void merge(int u)
      { table.at(u) = op(table.at(2 * u), table.at(2 * u + 1)); }

  public:
    segment_tree(int sz, BinaryOp op, Value id):
      sz    (sz),
      n     (std::pow(2, int(std::log2(2 * sz - 1)))),
      N     (n * 2),
      op    (op),
      id    (id),
      table (N, id)
      {}

    auto& at(int i)       { return table.at(n + i); }
    auto& at(int i) const { return table.at(n + i); }
    auto collect() const {
      auto ret = std::vector<Value>(sz);
      for (auto i = 0; i < sz; i++)
        { ret.at(i) = at(i); }
      return ret;
    }
    auto query(int l, int r) const {
      auto const dfs = [&](auto&& f, int l, int r, int k, int L, int R) -> Value {
        return l <= L && R <= r
          ? table.at(k)
          : R <= l || r <= L
          ? id
          : op(
            f(f, l, r, 2 * k, L, (L + R) / 2),
            f(f, l, r, 2 * k + 1, (L + R) / 2, R)
          );
      };
      return dfs(dfs, l, r, 1, 0, n);
    }
    void build_oneline(int i)
      { for (i += n, i /= 2; i > 0; i /= 2) merge(i); }
    void build()
      { for (auto i = n - 1; i > 0; i--) merge(i); }
};

template<typename Value, typename BinaryOp>
auto make_segment_tree(int sz, BinaryOp op, Value id)
  { return segment_tree<Value, BinaryOp>(sz, std::move(op), id); }

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint n, k; std::cin >> n >> k;
  std::vector<lint>a(n); std::cin>>a;
  for (lint & x : a) x-=k;
  std::partial_sum(all(a), a.begin());
  a.insert(a.begin(), 0);

  auto rank = [&] {
    std::vector<int> rank(n+1, -1);
    lint prv = std::numeric_limits<lint>::min();
    int now = -1;
    auto pairs = coenumerate(a);
    std::sort(all(pairs));
    for (auto&& pair : pairs) {
      lint x; int i; std::tie(x,i) = pair;
      assert(prv <= x);
      if (prv < x) now++;
      rank.at(i) = now;
      prv = x;
    }
    return rank;
  }();
  debug(rank);

  lint ans = 0;
  auto seg = make_segment_tree<int>(n+2,std::plus<>{},0);
  for (int x : rank) {
    ans += seg.query(0,x+1);
    seg.at(x)++;
    seg.build_oneline(x);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 7268