#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2010;
int N, a[MaxN], idx[MaxN], dp[MaxN][MaxN], res;
bool alive[MaxN];
vector<int> X, Y;
void add(int i) {
  int x = 0, y = 0;
  for (int j = i + 1; j < N; ++j)
    if (a[i] > a[j]) ++x;
  for (int j = 0; j < i; ++j)
    if (a[i] > a[j]) ++y;
  X.push_back(x);
  Y.push_back(y);
}
int main(void) {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
    if (a[i] < 0) a[i] *= -1;
    alive[i] = true;
  }
  for (int i = 0; i < N; ++i) {
    if (!alive[i]) continue;
    X.clear();
    Y.clear();
    for (int j = 0; j < N; ++j)
      if (a[j] == a[i]) {
        alive[j] = false;
        add(j);
      }
    for (int j = X.size(); j >= 0; --j) dp[X.size()][j] = 0;
    for (int j = X.size() - 1; j >= 0; --j)
      for (int plus = 0; plus <= j; ++plus)
        dp[j][plus] =
            min(dp[j + 1][plus + 1] + X[j], dp[j + 1][plus] + Y[j] + plus);
    res += dp[0][0];
  }
  printf("%d\n", res);
  return 0;
}
