#include <bits/stdc++.h>
using namespace std;
int in[2005];
int main() {
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> in[i], in[i] = abs(in[i]);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int x = 0;
    int y = 0;
    for (int j = 0; j < N; j++) {
      if (in[j] < in[i]) {
        if (j < i)
          x++;
        else
          y++;
      }
    }
    ans += min(x, y);
  }
  cout << ans << endl;
  return 0;
}
