#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, vector<int>> all;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < 0) a[i] *= -1;
    all[-a[i]].emplace_back(i);
  }
  int ans = 0;
  vector<int> active(n, 1);
  for (const auto &mp : all) {
    vector<int> cur = mp.second;
    int m = cur.size();
    vector<int> p(m), s(m);
    int score = 1e9;
    for (int i = 0; i < m; i++) {
      active[cur[i]] = 0;
    }
    for (int i = 0; i < (int)cur.size(); i++) {
      for (int j = 0; j < cur[i]; j++) {
        if (active[j]) {
          p[i]++;
        }
      }
      if (i > 0) p[i] += p[i - 1];
    }
    for (int i = int(cur.size()) - 1; i >= 0; i--) {
      for (int j = cur[i] + 1; j < n; j++) {
        if (active[j]) {
          s[i]++;
        }
      }
      if (i + 1 < (int)cur.size()) {
        s[i] += s[i + 1];
      }
    }
    score = min(p[m - 1], s[0]);
    for (int i = 0; i + 1 < (int)cur.size(); i++) {
      score = min(score, p[i] + s[i + 1]);
    }
    ans += score;
  }
  cout << ans << "\n";
  return 0;
}
