#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
struct node {
  int data, pos;
};
node a[maxn];
int n;
bool cmp(node a, node b) {
  if (a.data != b.data)
    return a.data > b.data;
  else
    return a.pos < b.pos;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].data);
    if (a[i].data < 0) a[i].data *= -1;
    a[i].pos = i;
  }
  sort(a + 1, a + 1 + n, cmp);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int cnt1, cnt2;
    cnt1 = cnt2 = 0;
    for (int j = 1; j <= n; j++)
      if (abs(a[j].data) < abs(a[i].data)) {
        if (a[j].pos < a[i].pos)
          cnt1++;
        else
          cnt2++;
      }
    if (cnt1 <= cnt2) {
      ans += cnt1;
      a[i].data = -a[i].data;
      if (a[i].data != 0)
        for (int j = 1; j <= n; j++)
          if (a[j].pos < a[i].pos && a[j].data == -a[i].data) {
            ans++;
          }
    } else {
      ans += cnt2;
    }
  }
  printf("%d\n", ans);
}
