#include <bits/stdc++.h>
using namespace std;
const int max_n = 2011, inf = 1e9 + 100;
int m[max_n];
int n;
int cnti = 0;
void calc_inv() {
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (m[i] > m[j]) {
        ++cnti;
      }
    }
  }
}
void upd(int ind) {
  for (int i = 0; i < n; ++i) {
    if (i == ind) continue;
    if (i < ind && m[i] > m[ind] || i > ind && m[i] < m[ind]) {
      --cnti;
    }
  }
  m[ind] = -m[ind];
  for (int i = 0; i < n; ++i) {
    if (i == ind) continue;
    if (i < ind && m[i] > m[ind] || i > ind && m[i] < m[ind]) {
      ++cnti;
    }
  }
}
int main() {
  cin >> n;
  vector<int> val;
  for (int i = 0; i < n; ++i) {
    cin >> m[i];
    m[i] = abs(m[i]);
    val.push_back(m[i]);
  }
  calc_inv();
  sort(val.begin(), val.end());
  val.erase(std::unique(val.begin(), val.end()), val.end());
  while (!val.empty()) {
    int cur = val.back();
    val.pop_back();
    int mn = cnti;
    int lstm = -1;
    for (int i = 0; i < n; ++i) {
      if (m[i] == cur) {
        upd(i);
        int cmn = cnti;
        if (cmn < mn) {
          mn = cmn;
          lstm = i;
        }
      }
    }
    for (int i = lstm + 1; i < n; ++i) {
      if (m[i] == -cur) {
        upd(i);
      }
    }
  }
  cout << cnti << endl;
  return 0;
}
