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