#include <bits/stdc++.h>
using namespace std;
int n, a, b, niz[2010], rez = 0;
int main(int argc, char** argv) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> niz[i];
    niz[i] = abs(niz[i]);
  }
  for (int i = 0; i < n; i++) {
    a = 0;
    b = 0;
    for (int j = 0; j < n; j++) {
      if (niz[i] > niz[j]) {
        if (i > j)
          a++;
        else if (j > i)
          b++;
      }
    }
    rez += min(a, b);
  }
  cout << rez;
  return 0;
}
