#include <bits/stdc++.h>
using namespace std;
int p[2005], l[2005], r[2005];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> p[i];
      if (p[i] < 0) p[i] = -p[i];
      l[i] = 0;
      r[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (p[j] < p[i])
          r[i]++;
        else if (p[j] > p[i])
          l[j]++;
      }
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      if (l[i] < r[i]) {
        p[i] = -p[i];
        ans += l[i];
      } else
        ans += r[i];
    }
    cout << ans << "\n";
  }
  return 0;
}
