#include <bits/stdc++.h>
using namespace std;
int main() {
  int ar[2000], n;
  scanf("%d", &n);
  for (unsigned i = 0; i < n; ++i) {
    scanf("%d", ar + i);
    ar[i] = abs(ar[i]);
  }
  unsigned res = 0;
  for (unsigned i = 0; i < n; ++i) {
    unsigned l = 0, r = 0;
    for (unsigned j = 0; j < i; ++j)
      if (ar[j] < ar[i]) ++l;
    for (unsigned j = i + 1; j < n; ++j)
      if (ar[j] < ar[i]) ++r;
    res += min(l, r);
  }
  printf("%d", res);
  return 0;
}
