Find minimum element in array for current operation and modify it i . e ; arr [ j ] -- > - arr [ j ]
for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { if ( $ arr [ $ j ] < $ min ) { $ min = $ arr [ $ j ] ; $ index = $ j ; } }