#include <bits/stdc++.h>
using namespace std;
int ints[2222];
int main() {
  int n;
  cin >> n;
  for (register int i = 1; i <= n; i++) cin >> ints[i];
  int ans = 0;
  for (register int i = 1; i <= n; i++) {
    int l = 0, r = 0;
    for (register int j = 1; j < i; j++)
      if (((ints[j] < 0) ? -(ints[j]) : (ints[j])) <
          ((ints[i] < 0) ? -(ints[i]) : (ints[i])))
        l++;
    for (register int j = i + 1; j <= n; j++)
      if (((ints[j] < 0) ? -(ints[j]) : (ints[j])) <
          ((ints[i] < 0) ? -(ints[i]) : (ints[i])))
        r++;
    ans += min(l, r);
  }
  cout << ans << endl;
  return (0);
}
