#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

struct SegNode {
    lc: Option<Box<SegNode>>,
    rc: Option<Box<SegNode>>,
    beg: usize,
    lst: usize,
    value: i64,
}
impl SegNode {
    fn new(b: usize, e: usize) -> SegNode {
        let piv = (b + e) / 2;
        let (lc, rc) = if b == piv {
            (None, None)
        } else {
            (Some(Box::new(SegNode::new(b, piv))), Some(Box::new(SegNode::new(piv, e))))
        };
        SegNode {
            lc: lc,
            rc: rc,
            beg: b,
            lst: e - 1,
            value: 0,
        }
    }
    fn get(&self, l: usize, r: usize) -> i64 {
        if l <= self.beg && self.lst <= r{
            #[cfg(local)] println!("{}: {:?}", "(self.beg, self.lst, l, r)", (self.beg, self.lst, l, r, self.value));
            self.value
        } else if r < self.beg || self.lst < l {
            0
        } else if let (&Some(ref lc), &Some(ref rc)) = (&self.lc, &self.rc) {
            lc.get(l, r) + rc.get(l, r)
        } else {
            //panic
            -1
        }
    }
    fn add(&mut self, l: usize, r: usize, num: i64) {
        if l <= self.beg && self.lst <= r{
            self.value += num;
            #[cfg(local)] println!("{}: {:?}", "num", (self.beg, self.lst, l, r, num, self.value));
        } else if r < self.beg || self.lst < l {
        } else if let (&mut Some(ref mut lc), &mut Some(ref mut rc)) = (&mut self.lc, &mut self.rc) {
            self.value += num * 1;
            lc.add(l, r, num);
            rc.add(l, r, num);
        }
    }
}
struct SegTree {
    size: usize,
    root: SegNode
}
impl SegTree {
    fn new(size: usize) -> SegTree {
        SegTree {
            size: size,
            root: SegNode::new(0, size),
        }
    }
    fn get(&self, l: usize, r: usize) -> i64 {
        self.root.get(l, min(self.size, r))
    }
    fn add(&mut self, l: usize, r: usize, num: i64) {
        self.root.add(l, min(self.size, r), num);
    }
}

fn main() {
    let input = readv::<i64>();
    let (n, k) = (input[0] as usize, input[1]);
    let mut cnt = 0;
    let mut accs: VecDeque<_> = (0..n)
        .map(|_| read::<i64>() - k)
        .map(|a| { cnt += a; cnt }).collect();
    accs.push_front(0);
    // let accs: Vec<_> = aa.into_iter().map(|a| { cnt += a; cnt }).collect();
    #[cfg(local)] println!("{}: {:?}", "accs", accs);

    let map = accs.iter().collect::<BTreeSet<_>>()
        .into_iter().enumerate().map(|(i, num)| (num, i)).collect::<HashMap<_, _>>();
    let seq = accs.iter().map(|i| map[i]).collect::<VecDeque<_>>();
    #[cfg(local)] println!("{}: {:?}", "seq", seq);

    let mut ans = 0i64;
    let mut st = SegTree::new(map.len());
    for i in seq.into_iter().rev() {
        ans += st.get(i, std::usize::MAX);
        // ans += st.get(i, -1isize as usize);
        st.add(i, i, 1);
        #[cfg(local)] println!("{}: {:?}", "(i, ans)", (i, ans));
    }
    println!("{}", ans);
}


Measured memory_bytes: 33008