#include <bits/stdc++.h>
using namespace std;
int ans, n, a[2005];
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < 0) a[i] = -a[i];
  }
  for (register int i = 1; i <= n; i++) {
    int l = 0, r = 0;
    for (register int j = 1; j < i; j++) {
      if (a[j] < a[i]) l++;
    }
    for (register int j = i + 1; j <= n; j++) {
      if (a[i] > a[j]) r++;
    }
    ans += min(l, r);
  }
  printf("%d\n", ans);
  return 0;
}
