If the lowest filling condition is void , then it is not possible to generate the required array
if ( $ n < $ mini ) { echo " - 1" ; return ; } $ rem = $ n - $ mini ; $ cnt = floor ( $ rem / $ k ) ; $ rem = $ rem % $ k ;