#include <bits/stdc++.h>
using namespace std;
int f[200010];
int n;
int a[2010];
int ans;
int main() {
  int i, j;
  int t1, t2;
  int s1, s2;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) {
    t1 = a[i];
    if (t1 < 0) t1 = t1 * -1;
    s1 = s2 = 0;
    for (j = 1; j < i; j++) {
      t2 = a[j];
      if (t2 < 0) t2 = t2 * -1;
      if (t2 < t1) s1++;
    }
    for (j = i + 1; j <= n; j++) {
      t2 = a[j];
      if (t2 < 0) t2 = t2 * -1;
      if (t2 < t1) s2++;
    }
    ans = ans + min(s1, s2);
  }
  printf("%d\n", ans);
  return 0;
}
