Purple rain falls on Linearland, a magic kingdom shaped like a straight, thin peninsula.
Professor Nelson Rogers looked at the rain closely and found that the purple rain is really a mix of red raindrops and blue raindrops.
He recorded the position and the color of the raindrops at many points along the peninsula. Reading the data, Professor Rogers wants to know which part of Linearland had the least purple rain.
He models the question like this. Divide the peninsula into n sections and number them 1 to n from west to east. Write R for a section whose rain was mostly red and B for a section whose rain was mostly blue, which gives a string of length n. Then find a block of consecutive sections in which the difference between the number of R and the number of B is largest. If a block holds r letters R and b letters B, the value to maximize is ∣r−b∣.