#include <bits/stdc++.h>
long a[2200];
long absl(long k) {
  if (k < 0) {
    k = 0 - k;
  }
  return k;
}
int main() {
  long i, j, n, ans, l, r;
  scanf("%ld", &n);
  for (i = 0; i < n; i++) {
    scanf("%ld", a + i);
    a[i] = absl(a[i]);
  }
  for (i = 0, ans = 0; i < n; i++) {
    for (j = 0, l = 0; j < i; j++) {
      if (a[j] < a[i]) {
        l++;
      }
    }
    for (j = i + 1, r = 0; j < n; j++) {
      if (a[j] < a[i]) {
        r++;
      }
    }
    if (l > r) {
      ans += r;
    } else {
      ans += l;
    }
  }
  printf("%ld\n", ans);
  return 0;
}
