#include <bits/stdc++.h>
using namespace std;
int a[2222], final[2222];
struct data {
  int x, pos;
  data(int _x = 0, int _pos = 0) : x(_x), pos(_pos) {}
  bool operator<(const data& b) const {
    return x < b.x || (x == b.x && pos < b.pos);
  }
} w[2222];
int main() {
  int(n);
  scanf("%d", &n);
  for (int i = (1); i < (n + 1); ++i) {
    final[i] = 100000000;
    scanf("%d", &(a[i]));
    a[i] = abs(a[i]);
    w[i] = data(a[i], i);
  }
  sort(w + 1, w + n + 1);
  int an = 0;
  for (int i = (1); i < (n + 1); ++i) {
    int cnt1 = 0, cnt2 = 0;
    for (int j = (1); j < (n + 1); ++j) {
      if (w[i].pos == j) continue;
      if (final[j] == 100000000) continue;
      if (j < w[i].pos) {
        if (final[j] > w[i].x) cnt1++;
        if (final[j] > -w[i].x) cnt2++;
      } else {
        if (final[j] < w[i].x) cnt1++;
        if (final[j] < -w[i].x) cnt2++;
      }
    }
    an += min(cnt1, cnt2);
    if (cnt2 <= cnt1)
      final[w[i].pos] = -w[i].x;
    else
      final[w[i].pos] = w[i].x;
  }
  printf("%d\n", an);
  return 0;
}
