#include <bits/stdc++.h>
using namespace std;
int n, s[2001], sum, a, b;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    s[i] = abs(s[i]);
  }
  for (int i = 0; i < n; i++) {
    a = b = 0;
    for (int j = 0; j < i; j++) a += (s[j] < s[i]);
    for (int j = n - 1; j > i; j--) b += (s[j] < s[i]);
    sum += min(a, b);
  }
  cout << sum << endl;
  return 0;
}
