#include <bits/stdc++.h>
using namespace std;
map<int, vector<int> > df;
int n, dp[2010][2010], tree[2010];
vector<int> cur;
void update(int ind, int val) {
  for (int i = ind; i < 2010; i += i & (-1 * i)) tree[i] += val;
}
int query(int ind) {
  int ans = 0;
  for (int i = ind; i > 0; i -= i & (-1 * i)) ans += tree[i];
  return ans;
}
int qrg(int a, int b) {
  if (a > b) return 0;
  if (a <= 1) return query(b);
  return query(b) - query(a - 1);
}
int fun(int a, int b) {
  if (a == cur.size()) return 0;
  if (dp[a][b] != -1) return dp[a][b];
  return dp[a][b] = min(qrg(1, cur[a]) + b + fun(a + 1, b),
                        qrg(cur[a], n) + fun(a + 1, b + 1));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    df[abs(x)].push_back(i + 1);
    update(i + 1, 1);
  }
  long long ans = 0;
  for (auto it = df.rbegin(); it != df.rend(); it++) {
    cur = it->second;
    for (auto val : cur) update(val, -1);
    for (int i = 0; i <= cur.size(); i++)
      for (int j = 0; j <= cur.size(); j++) dp[i][j] = -1;
    ans += fun(0, 0);
  }
  cout << ans << '\n';
}
