#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2007;
struct Point {
  int n, x;
  bool operator<(const Point &a) const {
    return x > a.x || x == a.x && n < a.n;
  }
};
int i, j, k, n, m, x, y, ans, cntl, cntr;
int a[MAXN];
Point b[MAXN];
int main() {
  while (cin >> n) {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (i = 0; i < n; i++) {
      cin >> x;
      a[i] = abs(x);
      b[i].n = i;
      b[i].x = a[i];
    }
    sort(b, b + n);
    ans = 0;
    for (i = 0; i < n; i++) {
      cntl = 0;
      cntr = 0;
      for (j = 0; j < i; j++) {
        if (a[j] < a[i]) {
          cntl++;
        }
      }
      for (j = i + 1; j < n; j++) {
        if (a[j] < a[i]) {
          cntr++;
        }
      }
      ans += min(cntl, cntr);
    }
    cout << ans << endl;
  }
  return 0;
}
