Sum of Beauty of All Substrings