#include <bits/stdc++.h>
using namespace std;
const int N = 200020;
int a[N], vis[N];
int main(void) {
  int n;
  scanf("%d", &n);
  priority_queue<pair<int, int> > pq;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    a[i] = abs(a[i]);
    pq.emplace(a[i], i);
  }
  int ans = 0;
  while (!pq.empty()) {
    int value, pos;
    tie(value, pos) = pq.top();
    pq.pop();
    int p = 0, neg = 0;
    for (int i = pos + 1; i < n; i++)
      if (!vis[i] and a[i] < value) p++;
    for (int i = pos - 1; i >= 0; i--)
      if (!vis[i] and a[i] < value) neg++;
    if (neg < p) a[pos] *= -1;
    vis[pos] = 1;
  }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (a[j] < a[i]) ans++;
  cout << ans << endl;
  return 0;
}
