#include <bits/stdc++.h>
const int maxn = 2020;
using namespace std;
int a, ar[maxn], dn[maxn][maxn], pre[maxn], suf[maxn];
bool used[maxn];
vector<int> w[maxn * 50];
int main() {
  scanf("%d", &a);
  for (int i = 1; i <= a; i++) {
    scanf("%d", &ar[i]);
    if (ar[i] < 0) ar[i] *= -1;
    if (!w[ar[i]].size()) w[ar[i]].push_back(0);
    w[ar[i]].push_back(i);
  }
  int maxx = 100000;
  long long ans = 0;
  for (int i = maxx; i >= 1; i--) {
    if (!w[i].size()) continue;
    for (int j = 0; j < w[i].size(); j++) used[w[i][j]] = 1;
    for (int j = 1; j <= a; j++) pre[j] = pre[j - 1] + (!used[j]);
    for (int j = a; j >= 1; j--) suf[j] = suf[j + 1] + (!used[j]);
    for (int j = 1; j < w[i].size(); j++)
      for (int k = 0; k < w[i].size(); k++) {
        if (k)
          dn[j][k] = suf[w[i][j] + 1] + dn[j - 1][k - 1];
        else
          dn[j][k] = 1e9;
        dn[j][k] = min(dn[j][k], (pre[w[i][j] - 1] + dn[j - 1][k] + k));
      }
    int mini = 1e9;
    for (int k = 0; k < w[i].size(); k++)
      mini = min(mini, (dn[w[i].size() - 1][k]));
    ans += mini;
    for (int j = 1; j < w[i].size(); j++)
      for (int k = 1; k < w[i].size(); k++) dn[j][k] = 0;
  }
  cout << ans << endl;
  return 0;
}
