#include <bits/stdc++.h>
using namespace std;
int read() {
  int f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + (s - '0');
    s = getchar();
  }
  return x * f;
}
int n, m, i, j, s, o, k;
int ABS(int x) { return x < 0 ? -x : x; }
int a[100005];
int sl[100005], sum[100005];
vector<int> c[100005];
int t[100005];
void addt(int x) {
  while (x <= 100001) t[x]++, x += ((-x) & (x));
}
int findt(int x) {
  int as = 0;
  while (x > 0) as += t[x], x -= ((-x) & (x));
  return as;
}
int main() {
  n = read();
  m = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    sl[i] = findt(ABS(a[i]));
    addt(ABS(a[i]) + 1);
    c[ABS(a[i])].push_back(i);
    m = max(m, ABS(a[i]));
  }
  for (int i = 0; i <= m; i++) {
    sum[i] = c[i].size();
    if (i > 0) sum[i] += sum[i - 1];
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    if (c[i].size()) {
      int as = 0, mins;
      for (int j = 0; j < c[i].size(); j++) {
        as += sum[i - 1] - sl[c[i][j]];
      }
      mins = as;
      for (int j = 0; j < c[i].size(); j++) {
        as += sl[c[i][j]] * 2 - sum[i - 1];
        mins = min(mins, as);
      }
      ans += mins;
    }
  }
  printf("%d\n", ans);
  return 0;
}
