#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 7, mod = 1e9 + 7, inf = 1e9 + 7;
const long long linf = (long long)1e18 + 7;
const long double eps = 1e-15, pi = 3.141592;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1},
          dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int n;
int a[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i] = abs(a[i]);
  for (int i = 1; i <= n; i++) {
    int l = 0, r = 0;
    for (int j = i + 1; j <= n; j++) l += a[i] > a[j];
    for (int j = 1; j <= i - 1; j++) l += a[j] > a[i];
    a[i] = -a[i];
    for (int j = i + 1; j <= n; j++) r += a[i] > a[j];
    for (int j = 1; j <= i - 1; j++) r += a[j] > a[i];
    if (l < r) a[i] = -a[i];
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) cnt += a[i] > a[j];
  printf("%d", cnt);
  exit(0);
}
