Opening Ceremony
The director of the Vekua Cup opening ceremony has devised a plan to introduce the n teams from various universities: a sequence of 2n individuals will appear on stage. Each university is represented by two participants in this sequence: the first carries a sign displaying the university's name in the language of the country it represents, and the second—ideally a child, as per the director's vision—holds a balloon (similar to the ACM ICPC tradition). Thus, the sequence consists of n individuals with signs and n children with balloons.
The participants have already lined up, but it turns out the sequence is disordered: in some places, two sign carriers are adjacent, and in others, children are grouped together. With so many participants, issuing commands to everyone simultaneously would result in chaos, so the director can only instruct two adjacent people to swap places. Since the order of university representation is not crucial (this is the opening ceremony, not the closing), the director's goal is to ensure the sequence starts with a sign carrier and that no two sign carriers or two children with balloons are adjacent anywhere in the sequence. The director seeks to determine the minimum number of swaps required to achieve this arrangement.
Input
The first line of the input contains a natural number n ≤ 10^6, representing the number of teams. The following 2n lines contain integers describing the sequence, starting from its "head": 0 if a child with a balloon is at that position, and 0 ≤ k ≤ 10^9 (a code representing the language of the sign) if a sign carrier is at that position.
Output
Output a single integer—the minimum number of swaps the director needs to make to achieve the desired alternation.