#include <bits/stdc++.h>
const int maxn = 2000 + 10;
int n;
int a[maxn];
int t1, t2;
int sum;
int main() {
  scanf("%d", &n);
  sum = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    t1 = 0;
    t2 = 0;
    for (int j = 1; j < i; j++)
      if (abs(a[j]) < abs(a[i])) t1++;
    for (int j = i + 1; j <= n; j++)
      if (abs(a[j]) < abs(a[i])) t2++;
    sum += t1 < t2 ? t1 : t2;
  }
  printf("%d\n", sum);
  return 0;
}
