#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int maxn = 2e3 + 10, maxm = 1e3 + 10, lg = 21, mod = 1e9 + 7, inf = 1e18;
int n, a[maxn];
int kg[maxn], kb[maxn];
bool ok[maxn];
int dp[maxn][maxn];
int gans(vector<int> &v) {
  for (int i = 0; i <= (int)(v.size()); i++)
    for (int j = 0; j <= (int)(v.size()); j++) dp[i][j] = mod;
  dp[0][0] = kb[v[0]];
  dp[0][1] = kg[v[0]];
  for (int i = 1; i < (int)(v.size()); i++) {
    dp[i][0] = dp[i - 1][0] + kb[v[i]];
    for (int j = 1; j <= i + 1; j++)
      dp[i][j] =
          min(dp[i - 1][j] + kb[v[i]], dp[i - 1][j - 1] + kg[v[i]] + i + 1 - j);
  }
  int ret = inf;
  for (int i = 0; i <= (int)(v.size()); i++)
    ret = min(ret, dp[(int)(v.size()) - 1][i]);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = abs(a[i]);
    for (int j = 0; j < i; j++) {
      if (a[j] < a[i]) kg[i]++;
      if (a[j] > a[i]) kb[j]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (!ok[i]) {
      vector<int> mos;
      for (int j = 0; j < n; j++)
        if (a[i] == a[j]) mos.push_back(j), ok[j] = 1;
      ans += gans(mos);
    }
  cout << ans;
  return 0;
}
