#include <bits/stdc++.h>
using namespace std;
long long n, a[2010], pre[2010], suf[2010], ans = 0;
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), a[i] = abs(a[i]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) pre[i] += (a[i] > a[j]);
    for (int j = n; j > i; j--) suf[i] += (a[i] > a[j]);
    ans += min(pre[i], suf[i]);
  }
  printf("%lld\n", ans);
}
