#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)2e3 + 100;
const int mod = (int)1e9 + 7;
const int P = (int)1e6 + 7;
const double pi = acos(-1.0);
inline long long R() {
  char c;
  long long ans = 0;
  bool started = 0, is_negative = 0;
  while (true) {
    c = getchar();
    if ((c < '0' || c > '9') && c != '-' && !started) continue;
    if ((c < '0' || c > '9') && c != '-' && started) break;
    if (started) ans = ans * 10ll;
    started = 1;
    if (c == '-')
      is_negative = 1;
    else
      ans += c - '0';
  }
  if (is_negative) ans = -ans;
  return ans;
}
int n, m, a[maxn], ans;
pair<int, int> b[maxn];
int main() {
  n = R();
  for (int i = (1); i <= (n); ++i) {
    a[i] = abs(R());
  }
  for (int i = (1); i <= (n); ++i) {
    int cnt1 = 0, cnt2 = 0;
    for (int j = (1); j <= (n); ++j) {
      if (i == j) continue;
      if (j < i) {
        if (a[j] > a[i]) cnt1++;
        if (a[j] > -a[i]) cnt2++;
      } else {
        if (a[i] > a[j]) cnt1++;
        if (-a[i] > a[j]) cnt2++;
      }
    }
    if (cnt1 >= cnt2) a[i] *= -1;
  }
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (i - 1); ++j) ans += (a[j] > a[i]);
  cout << ans;
}
