#include <bits/stdc++.h>
using namespace std;
int n;
int val[2002];
long long int dp[2002][2002];
bool use[2002][2002];
int bit[2002];
void add(int i, int x) {
  i++;
  while (i < 2002) {
    bit[i] += x;
    i += i & -i;
  }
}
int sum(int i) {
  int r = 0;
  i++;
  while (i) {
    r += bit[i];
    i -= i & -i;
  }
  return r;
}
int rng(int i, int j) {
  int S = sum(j);
  if (i) {
    S -= sum(i - 1);
  }
  return S;
}
vector<int> v;
inline long long int dfs(int a, int b, int nega) {
  if (a == n) {
    return 0;
  }
  if (a && val[v[a]] != val[v[a - 1]]) {
    b = nega = 0;
  }
  if (use[a][b]) {
    return dp[a][b];
  }
  if (b == 0 && nega == 0) {
    int id = a;
    while (id < v.size() && val[v[a]] == val[v[id]]) {
      add(v[id], -1);
      id++;
    }
  }
  use[a][b] = true;
  {
    long long int inv = rng(0, v[a]);
    inv += dfs(a + 1, b, nega + 1);
    dp[a][b] = inv;
  }
  {
    long long int inv = rng(v[a], n - 1);
    inv += nega;
    inv += dfs(a + 1, b + 1, nega);
    dp[a][b] = min(dp[a][b], inv);
  }
  if (b == 0 && nega == 0) {
    int id = a;
    while (id < v.size() && val[v[a]] == val[v[id]]) {
      add(v[id], 1);
      id++;
    }
  }
  return dp[a][b];
}
bool cmp(int a, int b) { return make_pair(val[a], a) > make_pair(val[b], b); }
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &val[i]);
    val[i] = abs(val[i]);
    v.push_back(i);
    add(i, 1);
  }
  sort(v.begin(), v.end(), cmp);
  long long int ans = dfs(0, 0, 0);
  printf("%lld\n", ans);
  return 0;
}
