If arr [ i ] > arr [ j ] then ticket can be brought from counter [ j + 1 , N ]
if ( arr [ i ] > arr [ j ] ) { ans = ans + min ( k , ( i - j ) ) * arr [ i ] ; k = k - ( i - j ) ; arr [ i ] -- ; } else {