题目描述
Background
Despite passing $Faded$, Xiao Mai still couldn't solve the Binary Puzzle.
Problem Description
Feeling a potential special correspondence between $0$ and $1$, she defined the "Inspiration Coefficient": the absolute value of the difference in positions (counting from the highest to the lowest) of two corresponding digits. She now wishes to pair $0$ with $1$ to maximize the sum of the Inspiration Coefficients under the condition of having the most correspondences.
The pairing rules are as follows:
- The correspondence must start with $0$ and end with $1$; in other words, each correspondence must have $0$ in the higher position and $1$ in the lower position.
- Multiple correspondences can be made, but they must not intersect. Intersection means sharing a common interval without being inclusive.
- For example, if one correspondence is between the 2nd and 4th positions, and another is between the 3rd and 5th positions, they cannot be chosen together because they intersect in the interval $[3, 4]$. However, if the correspondences are between the 1st and 5th positions and the 2nd and 4th positions, they do not intersect because they share the interval $[2, 4]$ but are inclusive and can be chosen together.

This means, intersection is not equivalent to overlap.
- Each digit can exist in at most one correspondence.
Input Format
The first line contains an integer $n$, the number of digits in the binary number.
The next line contains an $n$-digit binary number.
Output Format
A single line indicating the maximum sum of Inspiration Coefficients under the condition of having the most correspondences.
Sample Input and Output
Sample Input #1
2
10
Sample Output #1
0
Sample Input #2
6
110100
Sample Output #2
1
Notes
For 30% of the data, $0 < n <= 20$.
For 100% of the data, $0 < n <= 300$.
Sample Explanation
For Sample #1, since $1$ is before $0$, they cannot correspond.
For Sample #2, the correspondence is between positions 3 and 4, hence the sum is $1$.
If you finish early, you can try the Enhanced Version.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分