#include <bits/stdc++.h>
using namespace std;
const int T = 2 * 1e3 + 5;
int ans, A, B, tillnow, n, i, j, l, len;
int fix[T], s1[T], s2[T], d[T], a[T];
map<int, int> M;
long long dp[T][T];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i], a[i] = abs(a[i]);
  for (i = 0; i < n; i++)
    if (!M[a[i]]) {
      d[len++] = a[i];
      M[a[i]] = 1;
    }
  sort(d, d + len);
  reverse(d, d + len);
  vector<int> v;
  for (i = 0; i < len && n; i++) {
    v.clear();
    v.push_back(-1);
    for (j = 0; j < n; j++)
      if (a[j] == d[i]) v.push_back(j);
    v.push_back(n);
    l = v.size() - 1;
    long long mn = (long long)1000000500 * 1000000500;
    for (int I = 0; I <= l + 1; I++)
      for (int J = 0; J <= l + 1; J++) dp[I][J] = mn;
    dp[0][0] = 0;
    for (int I = 1; I <= l; I++)
      for (int J = 0; J <= I; J++) {
        dp[I][J] = (long long)1000000500 * 1000000500;
        if (J) {
          dp[I][J] = (dp[I][J] < dp[I - 1][J - 1] + v[I] - (J - 1) +
                                     (v[I] - v[I - 1] - 1) * (I - J)
                          ? dp[I][J]
                          : dp[I - 1][J - 1] + v[I] - (J - 1) +
                                (v[I] - v[I - 1] - 1) * (I - J));
        }
        dp[I][J] =
            (dp[I][J] < dp[I - 1][J] + (v[I] - v[I - 1] - 1) * (I - J - 1)
                 ? dp[I][J]
                 : dp[I - 1][J] + (v[I] - v[I - 1] - 1) * (I - J - 1));
        if (I == l) mn = (mn < dp[I][J] ? mn : dp[I][J]);
      }
    ans += mn;
    l = 0;
    for (j = 0; j < n; j++)
      if (a[j] != d[i]) a[l++] = a[j];
    n = l;
  }
  cout << ans << endl;
}
