#include <bits/stdc++.h>
using namespace std;
int a[2005], pos[100005], n;
long long ans;
pair<int, int> p[2005];
int main() {
  int i, j, k, l, r;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < 0) a[i] *= -1;
    p[i] = make_pair(a[i], i);
  }
  sort(p + 1, p + n + 1);
  for (int it = 1; it <= n; it++) {
    i = p[it].second;
    k = a[i];
    for (l = 0, j = 1; j < i; j++) l += (a[j] < k);
    for (r = 0, j = i + 1; j <= n; j++) r += (a[j] < k);
    if (l + pos[k] <= r) {
      ans += l + pos[k];
    } else {
      ans += r;
      pos[k]++;
    }
  }
  printf("%I64d\n", ans);
}
