#include <bits/stdc++.h>
using namespace std;
int n;
int x[2010];
int calc(int z, int t) {
  int v = 0;
  for (int i = 1; i < z; ++i) v += x[i] > t;
  for (int i = z + 1; i <= n; ++i) v += x[i] < t;
  return v;
}
int same(int z) {
  int v = 0;
  for (int i = 1; i < z; ++i)
    if (x[i] == x[z]) ++v;
  return v;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", x + i);
  for (int i = 1; i <= n; ++i) {
    int v = calc(i, x[i]) - calc(i, -x[i]);
    if (v > 0) x[i] = -x[i];
    if (v == 0 && x[i] > 0) x[i] = -x[i];
  }
  for (int i = n; i; --i) {
    int v = calc(i, x[i]) - calc(i, -x[i]);
    if (v > 0) x[i] = -x[i];
    if (v == 0 && x[i] < 0) x[i] = -x[i];
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) ans += x[i] > x[j];
  printf("%d", ans);
}
