#include <bits/stdc++.h>
using namespace std;
int a[10001];
int main() {
  int n, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < 0) a[i] = a[i] * -1;
  }
  for (int i = 0; i < n; i++) {
    int m = 0, p = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] < a[i]) {
        if (j < i) p++;
        if (i < j) m++;
      }
    }
    sum += min(p, m);
  }
  cout << sum << endl;
  return 0;
}
