n,k,*a=gets(p).split.map(&:to_i) ans=0 loop{ swapped=false 0.upto(n-k-1){|i| if a[i]>a[i+k] swapped=true ans+=1 a[i],a[i+k]=a[i+k],a[i] end } break unless swapped } puts a.each_cons(2).all?{|i,j|i