#include <bits/stdc++.h>
using namespace std;
const long long N = 2050;
signed main() {
  long long n, ans = 0;
  cin >> n;
  long long a[n];
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] = abs(a[i]);
  }
  for (long long i = 1; i <= n; ++i) {
    long long Num1 = 0, Num2 = 0;
    for (long long j = 1; j < i; ++j) {
      Num1 += a[j] < a[i];
    }
    for (long long j = i + 1; j <= n; ++j) {
      Num2 += a[j] < a[i];
    }
    ans += min(Num1, Num2);
  }
  cout << ans;
  return 0;
}
