#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1000 + 10;
int dp[maxn][2], p[maxn];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i] = (p[i] > 0 ? p[i] : -p[i]);
    for (int j = 0; j < i; j++) {
      if (p[i] < p[j]) dp[j][0]++;
      if (p[i] > p[j]) dp[i][1]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans += min(dp[i][0], dp[i][1]);
  cout << ans;
  return 0;
}
