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