#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, a[N], l, r, ans;
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) a[i] = read();
  for (register int i = 1; i <= n; i++) {
    l = 0, r = 0;
    for (register int j = 1; j <= n; j++) {
      if (i == j) continue;
      if (abs(a[j]) < abs(a[i])) {
        if (j < i)
          l++;
        else if (j > i)
          r++;
      }
    }
    ans += min(l, r);
  }
  printf("%d\n", ans);
  return 0;
}
