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