Convert all frequencies to nearest smaller even values .
arr1 = [ ] NEW_LINE for i in freq_2 : NEW_LINE arr1 . extend ( [ i ] * ( freq_2 [ i ] // 2 ) * 2 ) NEW_LINE arr1 . sort ( reverse = True ) NEW_LINE