#include <bits/stdc++.h>
using namespace std;
int n, arr[2010];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &arr[i]), arr[i] = abs(arr[i]);
  int out = 0;
  for (int i = 0; i < n; ++i) {
    int c1 = 0, c2 = 0;
    for (int j = 0; j < n; ++j) {
      if (i == j || arr[j] >= arr[i]) continue;
      if (j < i)
        ++c1;
      else
        ++c2;
    }
    out += min(c1, c2);
  }
  cout << out;
}
