#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
long long n, m = 0, m0 = 0, res = 0, sum = 0, sum0 = 0, maxx = -100000,
             minn = 100000009, coun = 0, coun0;
long long p[30009];
class par {
 public:
  int x, y;
  bool operator<(const par p) const {
    if (abs(y) != abs(p.y)) {
      return (abs(y) < abs(p.y));
    } else
      return (abs(x) < abs(p.x));
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i] = abs(p[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (p[j] > p[i]) sum++;
    }
  }
  for (int i = 0; i < n; i++) {
    m0 = 0;
    sum0 = 0;
    for (int j = 0; j < i; j++) {
      if (p[j] > -p[i]) m0++;
      if (p[j] >= p[i]) {
        m0--;
        m++;
      }
    }
    for (int j = i + 1; j < n; j++) {
      if (abs(p[i]) > p[j]) sum0++;
    }
    if (sum0 >= m0) {
      sum -= sum0;
      m += m0;
      p[i] = -p[i];
    }
    if (minn > m + sum) {
      minn = m + sum;
    }
  }
  sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (p[j] > p[i]) sum++;
    }
  }
  cout << sum;
  int kol234;
  cin >> kol234;
}
