#include <bits/stdc++.h>
using namespace std;
int tree1[400090], tree2[400090], m, n, a[400090];
int query(int tree[], int idx) {
  idx += 2e5 + 1;
  int s = 0;
  while (idx > 0) {
    s += tree[idx];
    idx -= idx & (-idx);
  }
  return s;
}
void update(int tree[], int idx, int val) {
  idx += 2e5 + 1;
  while (idx < 400090) {
    tree[idx] += val;
    idx += idx & (-idx);
  }
}
long long int ans = 0;
void solve(int n) {
  for (int i = 0; i < n; i++) {
    update(tree2, a[i], 1);
  }
  long long int x, y;
  for (int i = 0; i < n; i++) {
    x = query(tree1, 1e5) - query(tree1, a[i]) + query(tree2, a[i] - 1);
    y = query(tree1, 1e5) - query(tree1, -a[i]) + query(tree2, -a[i] - 1);
    update(tree2, a[i], -1);
    if (x > y) {
      a[i] = -a[i];
      ans += y - x;
    }
    update(tree1, a[i], 1);
  }
}
int main() {
  int i, j;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = abs(a[i]);
  }
  for (i = 0; i < n; i++) {
    for (j = i - 1; j >= 0; j--) {
      if (a[i] < a[j]) {
        ans++;
      }
    }
  }
  solve(n);
  cout << ans;
  ;
  return 0;
}
