#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    if (p[i] < 0) {
      p[i] = -p[i];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int L = 0, R = 0;
    for (int j = 0; j < n; ++j) {
      if (p[j] < p[i]) {
        ++(j < i ? L : R);
      }
    }
    ans += min(L, R);
  }
  cout << ans;
  return 0;
}
