#include <bits/stdc++.h>
using namespace std;
inline int setBit(int N, int pos) { return N = N | (1 << pos); }
inline int resetBit(int N, int pos) { return N = N & ~(1 << pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); }
int n, A[2000 + 10];
pair<int, int> val[2000 + 10];
int pre() {
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      if (abs(A[i]) > abs(A[j])) val[i].second++, val[i].first--;
    }
    for (int j = i + 1; j <= n; j++) {
      if (A[i] > A[j] && abs(A[i]) != abs(A[j])) ret++;
      if (abs(A[i]) > abs(A[j])) val[i].second--, val[i].first++;
    }
  }
  return ret;
}
map<int, int> M;
vector<pair<int, int> > V;
int dp[2000 + 10][2000 + 10], vis[2000 + 10][2000 + 10], cs;
int call(int pos, int positive) {
  if (pos == V.size()) return 0;
  int &ret = dp[pos][positive];
  if (vis[pos][positive] == cs) return ret;
  vis[pos][positive] = cs;
  ret = min(call(pos + 1, positive + 1) + V[pos].first,
            call(pos + 1, positive) + positive + V[pos].second);
  return ret;
}
int B[2000 + 10];
void brute() {
  int ret = 1e9;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 1; j <= n; j++) {
      B[j] = A[j];
      if (checkBit(i, j - 1)) B[j] *= -1;
    }
    int tmp = 0;
    for (int j = 1; j <= n; j++) {
      for (int k = j + 1; k <= n; k++) {
        if (B[j] > B[k]) tmp++;
      }
    }
    if (tmp == 6) {
      for (int j = 1; j <= n; j++) cout << B[j] << " ";
      cout << endl;
      return;
    }
    ret = min(ret, tmp);
  }
  cerr << 82 << ": "
       << "ret"
       << " = " << (ret) << '\n';
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]), M[abs(A[i])] = true;
  int ans = pre();
  for (auto m : M) {
    V.clear();
    for (int i = 1; i <= n; i++) {
      if (abs(A[i]) == m.first) {
        if (A[i] > 0)
          V.push_back({0, val[i].second});
        else if (A[i] < 0)
          V.push_back({val[i].first, 0});
      }
    }
    cs++;
    ans += call(0, 0);
  }
  cout << ans << endl;
  return 0;
}
