#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int p[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    p[i] = abs(p[i]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int a = 0, b = 0;
    for (int j = 1; j < i; j++) {
      if (p[j] < p[i]) a++;
    }
    for (int j = i + 1; j <= n; j++) {
      if (p[j] < p[i]) b++;
    }
    ans += 1ll * min(a, b);
  }
  cout << ans << endl;
}
