#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
int n, arr[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int in;
    scanf("%d", &in);
    arr[i] = abs(in);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int inv_kiri = 0, inv_kanan = 0;
    for (int j = 0; j < i; j++) {
      if (arr[j] < arr[i]) inv_kiri++;
    }
    for (int j = i + 1; j < n; j++) {
      if (arr[j] < arr[i]) inv_kanan++;
    }
    ans += min(inv_kiri, inv_kanan);
  }
  printf("%d\n", ans);
  return 0;
}
