#include <bits/stdc++.h>
using namespace std;
int n, m, a[1000005];
long long ans;
int main() {
  cin >> n;
  for (int i = (1); i <= (n); ++i) {
    cin >> a[i];
    a[i] = abs(a[i]);
  }
  for (int i = (1); i <= (n); ++i) {
    int L = 0, R = 0;
    for (int j = (1); j <= (i - 1); ++j) {
      if (a[j] < a[i]) L++;
    }
    for (int j = (i + 1); j <= (n); ++j) {
      if (a[j] < a[i]) R++;
    }
    ans += min(L, R);
  }
  cout << ans;
}
