#include <bits/stdc++.h>
using namespace std;
int ar[2001], res[2001], out;
pair<int, int> srt[2001];
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    ar[i] = abs(ar[i]);
    srt[i] = {ar[i], i};
    res[i] = 1000000000;
  }
  sort(srt, srt + n);
  for (int i = 0; i < n; i++) {
    int l = 0, r = 0;
    for (int j = 0; j < srt[i].second; j++) {
      l += abs(res[j]) < srt[i].first;
    }
    for (int j = srt[i].second + 1; j < n; j++) {
      r += abs(res[j]) < srt[i].first;
    }
    if (l < r) {
      out += l;
      res[srt[i].second] = -srt[i].first;
    } else {
      out += r;
      res[srt[i].second] = srt[i].first;
    }
  }
  cout << out << "\n";
  return 0;
}
