#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 100;
int ja[maxn];
int a[maxn];
vector<pair<int, int> > vec;
int main() {
  ios::sync_with_stdio(false);
  long long n = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] = abs(a[i]);
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    long long cur = 0;
    long long cur2 = 0;
    for (int j = 0; j < n; ++j)
      if (a[i] > a[j]) {
        if (i < j)
          cur++;
        else
          cur2++;
      }
    ans += min(cur, cur2);
  }
  cout << ans << endl;
  return 0;
}
