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