#include <bits/stdc++.h>
using namespace std;
const int SIZE = 2 << 10;
const int MAXV = 1 << 17;
int n;
int arr[SIZE];
vector<int> elems[MAXV];
int fenw[SIZE];
inline int h(int x) { return ((x ^ (x + 1)) + 1) >> 1; }
void Add(int x, int add) {
  for (int i = x; i < SIZE; i += h(i)) fenw[i] += add;
}
int GetSum(int cnt) {
  int res = 0;
  for (int i = cnt - 1; i >= 0; i -= h(i)) res += fenw[i];
  return res;
}
int res[SIZE][SIZE];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    arr[i] = abs(arr[i]);
  }
  for (int i = 0; i < n; i++) elems[arr[i]].push_back(i);
  int ans = 0;
  for (int k = 0; k < MAXV; k++) {
    const auto& v = elems[k];
    if (v.empty()) continue;
    int s = v.size();
    int tans = 1000000000;
    for (int i = 0; i <= s; i++)
      for (int j = 0; j <= s; j++) res[i][j] = 1000000000;
    res[0][0] = 0;
    for (int i = 0; i < s; i++)
      for (int j = 0; j <= i; j++) {
        int tres = res[i][j];
        if (tres >= 1000000000) continue;
        int kleft = GetSum(v[i] + 1);
        int kright = GetSum(n) - kleft;
        res[i + 1][j] = min(res[i + 1][j], tres + (k == 0 ? 0 : j) + kleft);
        res[i + 1][j + 1] = min(res[i + 1][j + 1], tres + kright);
      }
    for (int j = 0; j <= s; j++) tans = min(tans, res[s][j]);
    ((void)0);
    ((void)0);
    ans += tans;
    for (int i = 0; i < v.size(); i++) Add(v[i], 1);
  }
  printf("%d\n", ans);
  return 0;
}
