give integer array num goal element num equal to complete operation follow stepsfind large value num let index 0indexed value large if multiple element large value pick small ifind large value num strictly small large let value nextlargestreduce numsi nextlargestreturn number operation element num equal Example 1input num 513output 3explanation it take 3 operation element num equal1 large 5 index 0 nextlarg 3 Reduce nums0 3 num 3132 large 3 index 0 nextlarg 1 Reduce nums0 1 num 1133 large 3 index 2 nextlarg 1 reduce nums2 1 num 111example 2input num 111output 0explanation all element num equalexample 3input num 11223output 4explanation it take 4 operation element num equal1 large 3 index 4 nextlarg 2 Reduce nums4 2 num 112222 large 2 index 2 nextlarg 1 reduce nums2 1 num 111223 large 2 index 3 nextlarg 1 Reduce nums3 1 num 111124 large 2 index 4 nextlarg 1 Reduce nums4 1 num 11111 Constraints1 numslength 5 1041 numsi 5 104