#include <bits/stdc++.h>
using namespace std;
int p[2010];
int main(void) {
  int N, ans = 0, i, j;
  cin >> N;
  for ((i) = 0; (i) < (int)(N); (i)++) cin >> p[i];
  for ((i) = 0; (i) < (int)(N); (i)++)
    if (p[i] < 0) p[i] = -p[i];
  for ((i) = 0; (i) < (int)(N); (i)++) {
    int a = 0, b = 0;
    for ((j) = 0; (j) < (int)(N); (j)++)
      if (p[j] < p[i]) {
        if (j < i) a++;
        if (j > i) b++;
      }
    ans += min(a, b);
  }
  cout << ans << endl;
  return 0;
}
