#include <bits/stdc++.h>
using namespace std;
int mx, n, i, u, r, k, j, mn, ans, x;
vector<int> a, na, P;
int dp[2048][2048];
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a.push_back(abs(x));
  }
  while (!a.empty()) {
    mx = -1;
    n = (int)a.size();
    P.clear();
    k = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] > mx) {
        P.clear();
        P.push_back(i);
        mx = a[i];
        k = 1;
      } else if (a[i] == mx)
        P.push_back(i), k++;
    }
    for (int i = 0; i <= k; i++)
      for (int j = 0; j <= k; j++) dp[i][j] = 1e9;
    dp[0][0] = 0;
    for (int i = 0; i < k; i++)
      for (int j = 0; j <= i; j++) {
        dp[i + 1][j + 1] =
            min(dp[i + 1][j + 1], dp[i][j] + n - P[i] - 1 - k + i + 1);
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + P[i] - (i - j));
      }
    mn = 1e9;
    for (int i = 0; i <= k; i++) mn = min(mn, dp[k][i]);
    ans += mn;
    na.clear();
    for (int i = 0; i < n; i++)
      if (a[i] != mx) na.push_back(a[i]);
    a = na;
  }
  cout << ans << "\n";
  return 0;
}
