#include <bits/stdc++.h>
using namespace std;
struct cara {
  int pos, val;
};
const int MAXN = 2100;
int v[MAXN], td[MAXN], te[MAXN], tira[MAXN];
cara m[MAXN];
bool comp(cara a, cara b) { return a.val > b.val; }
int main() {
  int n;
  scanf("%d", &n);
  for (int c = 1; c <= n; c++) scanf("%d", &v[c]);
  for (int c = 1; c <= n; c++) v[c] = max(v[c], -v[c]);
  for (int c = 1; c <= n; c++) {
    m[c].val = v[c];
    m[c].pos = c;
  }
  sort(&m[1], &m[n + 1], comp);
  int res = 0;
  int E, D;
  for (int c = 1; c <= n; c++) {
    E = D = 0;
    for (int g = 1; g <= n; g++) {
      if (g < c && v[g] >= v[c]) E++;
      if (g > c && v[g] >= v[c]) D++;
    }
    res += min(c - 1 - E, n - c - D);
  }
  printf("%d", res);
  return 0;
}
