If frequency of maximum is even , then add 2 * maxNumber . Otherwise , add maxNumber
if count % 2 : NEW_LINE INDENT ans += maxNumber NEW_LINE DEDENT else : NEW_LINE INDENT ans += maxNumber * 2 NEW_LINE DEDENT