The package for this problem was not updated by the problem writer or Codeforces administration after we've upgraded the judging servers. To adjust the time limit constraint, a solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then the value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
E. Jeff and Permutation

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputJeff'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.

Input

The first line contains integer *n* (1 ≤ *n* ≤ 2000). The next line contains *n* integers — sequence *p*_{1}, *p*_{2}, ..., *p*_{n} (|*p*_{i}| ≤ 10^{5}). The numbers are separated by spaces.

Output

In a single line print the answer to the problem — the minimum number of inversions Jeff can get.

Examples

Input

2

2 1

Output

0

Input

9

-2 0 -1 0 -1 2 1 0 -1

Output

6

Codeforces (c) Copyright 2010-2022 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/25/2022 13:52:18 (i2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|