#include <bits/stdc++.h>
using namespace std;
int n, a[2000 + 9];
int main() {
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a[i]);
      if (a[i] > 0) a[i] = -a[i];
    }
    int tot = 0;
    for (int i = 0; i < n; ++i)
      for (int j = i + 1; j < n; ++j)
        if (a[i] > a[j]) ++tot;
    bool change;
    do {
      change = false;
      for (int t = n - 1; t >= 0; --t) {
        int s1 = 0, s2 = 0;
        for (int i = 0; i < n; ++i)
          if (i < t && a[i] > a[t] || i > t && a[i] < a[t]) ++s1;
        for (int i = 0; i < n; ++i)
          if (i < t && a[i] > -a[t] || i > t && a[i] < -a[t]) ++s2;
        if (s2 < s1) {
          tot += s2 - s1;
          a[t] = -a[t];
          change = true;
        }
      }
    } while (change);
    printf("%d\n", tot);
  }
  return 0;
}
