#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n, a[N], b[N], np, ans = 0, s1[N], s2[N], c[N];
int msum(int x) {
  int res = 0;
  for (int i = x; i; i -= i & -i) res += c[i];
  return res;
}
void upd(int x, int d) {
  for (int i = x; i <= n; i += i & -i) c[i] += d;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]), a[i] = abs(a[i]), b[i] = a[i];
  sort(b + 1, b + 1 + n);
  np = unique(b + 1, b + 1 + n) - b - 1;
  for (int i = 1; i <= n; i++) {
    a[i] = lower_bound(b + 1, b + 1 + np, a[i]) - b;
  }
  for (int i = 1; i <= n; i++) {
    s1[i] = msum(a[i] - 1);
    upd(a[i], 1);
  }
  memset(c, 0, sizeof(c));
  for (int i = n; i >= 1; i--) {
    s2[i] = msum(a[i] - 1);
    upd(a[i], 1);
  }
  for (int i = 1; i <= n; i++) ans += min(s1[i], s2[i]);
  printf("%d", ans);
  return 0;
}
