#include <bits/stdc++.h>
const int NN = 2010;
int N;
int a[NN];
int b[NN];
int main() {
  while (scanf("%d", &N) == 1) {
    for (int i = 0; i < N; i++)
      scanf("%d", &a[i]), b[i] = a[i] > 0 ? a[i] : -a[i];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int c1 = 0, c2 = 0;
      for (int j = 0; j < i; j++) {
        if (b[j] < b[i]) c1++;
      }
      for (int j = i + 1; j < N; j++) {
        if (b[j] < b[i]) c2++;
      }
      ans += (c1) < (c2) ? (c1) : (c2);
    }
    printf("%d\n", ans);
  }
  return 0;
}
