#include <bits/stdc++.h>
using namespace std;
int n, i, j, x, y, ans, p[3100];
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    scanf("%d", &p[i]), p[i] = ((p[i]) > 0 ? (p[i]) : -(p[i]));
  for (i = 1; i <= n; i++) {
    for (x = 0, j = 1; j < i; j++) x += (p[j] < p[i]);
    for (y = 0, j = i + 1; j <= n; j++) y += (p[j] < p[i]);
    ans += ((x) < (y) ? (x) : (y));
  }
  printf("%d\n", ans);
}
