Question
Minimum Adjacent Swaps to Sort a Binary Array

You are given a binary array. Adjacent elements may be swapped. Find the minimum number of adjacent swaps needed to make all 0s appear before all 1s.

Input

The first line contains KaTeX can only parse string typed expression. The second line contains KaTeX can only parse string typed expression values, each either KaTeX can only parse string typed expression or KaTeX can only parse string typed expression.

Output

Print the minimum number of adjacent swaps.

Example
Example:
Input
5

1 0 1 0 1
Output
3

Online