#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int n;
int mass[2000];
int tmpl[2000];
int buff[2000];
long long invert(int l, int r) {
  long long res = 0;
  if (l >= r) return 0;
  int m = (l + r) / 2;
  res += invert(l, m);
  res += invert(m + 1, r);
  int a = l, b = m + 1;
  int i = l;
  while (a <= m && b <= r) {
    if (tmpl[a] <= tmpl[b])
      buff[i++] = tmpl[a++];
    else {
      res += (m - a + 1);
      buff[i++] = tmpl[b++];
    }
  }
  while (a <= m) buff[i++] = tmpl[a++];
  while (b <= r) buff[i++] = tmpl[b++];
  for (i = l; i <= r; i++) tmpl[i] = buff[i];
  return res;
}
long long dInv(int pos) {
  int answ = 0;
  int w = -mass[pos], m = mass[pos];
  for (int i = 0; i < pos; i++) {
    if (mass[i] > w && mass[i] <= m) answ++;
    if (mass[i] <= w && mass[i] > m) answ--;
  }
  for (int i = pos + 1; i < n; i++) {
    if (mass[i] >= w && mass[i] < m) answ--;
    if (mass[i] < w && mass[i] >= m) answ++;
  }
  return answ;
}
int main() {
  bool end = false;
  int inv;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &mass[i]);
    tmpl[i] = mass[i];
  }
  inv = invert(0, n - 1);
  while (!end) {
    end = true;
    for (int pos = 0; pos < n; pos++) {
      int d = dInv(pos);
      if (d < 0) {
        inv += d;
        mass[pos] *= -1;
        end = false;
      }
    }
  }
  printf("%d\n", inv);
  return 0;
}
