class Array
    def bsearch_last_index(l = 0, r = size - 1, &pred)
        return nil if l > r
        c = (l + r) / 2 
        if pred[self[c]]
            bsearch_last_index(c+1, r, &pred) || c
        else
            bsearch_last_index(l, c-1, &pred)
        end
    end
end

loop do
    n, s = gets.split.map(&:to_i)
    break if n == 0
    rs = (1..n).map { gets.to_i }

    if n == 1
        puts 0
        next
    end

    num = 0
    (0..n-2).each do |i|
        j = rs.bsearch_last_index {|x| rs[i] + x < s}
        break if j == n - 1
        if !j
            num += n - 1 - i
        elsif j <= i
            num += n - 1 - i
        else
            num += n - 1 - j
        end
    end
    p num
end