Jeff's friends know full well that the boy likes to get sequences and arrays for his birthday. Thus, Jeff got sequence p 1, p 2, ..., p n for his birthday. Jeff hates inversions in sequences. An inversion in sequence a 1, a 2, ..., a n is a pair of indexes i, j (1 ≤ i j ≤ n), such that an inequality a i a j holds. Jeff can multiply some numbers of the sequence p by -1. At that, he wants the number of inversions in the sequence to be minimum. Help Jeff and find the minimum number of inversions he manages to get.
输入描述:
The first line contains integer n(1 ≤ n ≤ 2000). The next line contains n integers — sequence p1, p2, ..., pn(pi ≤ 105). The numbers are separated by spaces.


输出描述:
In a single line print the answer to the problem — the minimum number of inversions Jeff can get.
示例1

输入

2<br />2 1<br />9<br />-2 0 -1 0 -1 2 1 0 -1<br />

输出

0<br />6<br />
加载中...