Staircase function/Sum product maximum minimum/Exercise