in reply to find maximum occuring element in a array

The only way to find the maximum element of a list is to inspect every one to make sure it is not bigger than the element you're currently thinking of.

A for loop would do nicely. Track your best result, and a count of how many times you have seen it. Then return (($best) x $count);

Edit: Of course, if by maximum you don't mean dictionary order where QS would come last, ignore this.