#include <bits/stdc++.h>
using namespace std;
int n;
int a[20001], ans;
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] = abs(a[i]);
  }
  for (register int i = 1; i <= n; i++) {
    int suml = 0, sumr = 0;
    for (register int j = 1; j <= n; j++) {
      if (i == j) continue;
      if (a[i] > a[j]) {
        if (j < i)
          suml++;
        else
          sumr++;
      }
    }
    ans += min(suml, sumr);
  }
  printf("%d", ans);
  return 0;
}
