#include <bits/stdc++.h>
using namespace std;
int s[2100], a[2100], b[2100];
int n, r[2100];
vector<int> f[2100];
int dp[2100][2100];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    r[i] = s[i] = abs(s[i]);
  }
  sort(r, r + n);
  int m = unique(r, r + n) - r;
  for (int i = 0; i < n; ++i) s[i] = lower_bound(r, r + m, s[i]) - r;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < i; ++j)
      if (s[j] < s[i]) b[i]++;
    for (int j = i + 1; j < n; ++j)
      if (s[j] < s[i]) a[i]++;
    f[s[i]].push_back(i);
  }
  int res = 0;
  for (int i = 0; i < m; ++i) {
    dp[0][1] = a[f[i][0]];
    dp[0][0] = b[f[i][0]];
    int sz = f[i].size() - 1;
    for (int j = 1; j <= sz; ++j) {
      int ii = f[i][j];
      dp[j][0] = dp[j - 1][0] + b[ii];
      for (int k = 1; k <= j; ++k)
        dp[j][k] = min(dp[j - 1][k] + b[ii] + k, dp[j - 1][k - 1] + a[ii]);
      dp[j][j + 1] = dp[j - 1][j] + a[ii];
    }
    int ans = n * n;
    for (int i = 0; i <= sz + 1; ++i) ans = min(ans, dp[sz][i]);
    res += ans;
  }
  cout << res << endl;
  return 0;
}
