Ran is good at solving graph problems, but this time she has a great trouble because the problem Yukari gives her is too hard! Ran needs your help!
So here's the Circle of Mistery Problem:
Give an integer array www of length nnn and an integer kkk. Ran needs to construct a permutaion ppp. Let's use ppp to construct a graph: connect iii and pip_ipi together. Obviously, the graph will contain several circles. Ran has to make sure at least one circle a1→a2→⋯→ax→a1a_1\to a_2\to\dots\to a_x\to a_1a1→a2→⋯→ax→a1 (x≥1x\ge1x≥1) satisfy that ∑i=1xwai≥k\sum_{i=1}^x w_{a_i}\ge k∑i=1xwai≥k. That means, circle a1→a1a_1\to a_1a1→a1 is legal.
Try to find the permutation ppp with the minimum number of inversions and output the number. An inversion in an array aaa is a pair of indices (i,j)(i, j)(i,j) such that i>ji > ji>j and ai<aja_i < a_jai<aj.