#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000 + 10;
const int MAXA = 100000 + 10;
int n;
int a[MAXN];
int cnt(int x, int i) {
  int res = 0;
  for (int j = 0; j < i; j++)
    if (abs(a[j]) <= abs(x) && a[j] > x) res++;
  for (int j = i + 1; j < n; j++)
    if (abs(a[j]) <= abs(x) && x > a[j]) res++;
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    if (a[i] < 0) a[i] = -a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x = cnt(a[i], i), y = cnt(-a[i], i);
    if (x < y)
      ans += x;
    else
      ans += y, a[i] = -a[i];
  }
  printf("%d\n", ans);
  return 0;
}
