#include <bits/stdc++.h>
using namespace std;
const int SIZEN = 2010;
int N;
int A[SIZEN] = {0};
void work(void) {
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int x = 0, y = 0;
    for (int j = 1; j <= N; j++) {
      if (A[i] > A[j]) {
        if (i > j)
          x++;
        else
          y++;
      }
    }
    ans += min(x, y);
  }
  printf("%d\n", ans);
}
void read(void) {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
    A[i] = abs(A[i]);
  }
}
int main() {
  read();
  work();
  return 0;
}
