#include <bits/stdc++.h>
using namespace std;
int a[2010], vis[2010], pre[2010], suc[2010];
pair<int, int> b[2010];
int cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return a.first > b.first;
}
void lemon() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%d", &a[i]), a[i] = abs(a[i]);
  for (int i = (1); i <= (n); i++) b[i] = make_pair(a[i], i);
  sort(b + 1, b + n + 1, cmp);
  for (int i = (1); i <= (n); i++) vis[i] = 1;
  int cur = 1, final = 0;
  while (cur <= n) {
    int ne = cur;
    while (ne <= n && b[cur].first == b[ne].first) ne++;
    for (int i = (cur); i <= (ne - 1); i++) vis[b[i].second] = 0;
    pre[0] = 0;
    for (int i = (1); i <= (n); i++) pre[i] = pre[i - 1] + vis[i];
    suc[n + 1] = 0;
    for (int i = (n); i >= (1); i--) suc[i] = suc[i + 1] + vis[i];
    for (int i = (cur); i <= (ne - 1); i++)
      final += min(pre[b[i].second], suc[b[i].second]);
    cur = ne;
  }
  cout << final << endl;
}
int main() {
  ios::sync_with_stdio(true);
  lemon();
  return 0;
}
