Store the frequencies of all the distinct primes
b = [ ] NEW_LINE dp = [ ] NEW_LINE sum = 0 NEW_LINE i = 0 NEW_LINE while i < l : NEW_LINE INDENT count = 1 NEW_LINE x = a [ i ] NEW_LINE i += 1 NEW_LINE while ( i < l and a [ i ] == x ) : NEW_LINE INDENT count += 1 NEW_LINE i += 1 NEW_LINE DEDENT DEDENT