#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000009;
int sum[102055], a[102055];
int ans = 0;
void add(int i) {
  while (i) sum[i]++, i -= i & -i;
}
int query(int i) {
  int ans = 0;
  while (i < 102055) {
    ans += sum[i], i += i & -i;
  }
  return ans;
}
int n;
int lft[102055], rht[102055];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    a[i] = abs(a[i]) + 1;
    ans += query(a[i] + 1);
    add(a[i]);
  }
  memset(sum, 0, sizeof(sum));
  int tmp;
  for (int i = 1; i <= n; ++i) {
    tmp = query(a[i]);
    add(a[i]);
    lft[i] = i - tmp;
  }
  memset(sum, 0, sizeof(sum));
  for (int i = n; i >= 1; --i) {
    tmp = query(a[i]);
    add(a[i]);
    rht[i] = n - i + 1 - tmp;
    if (rht[i] > lft[i]) ans -= rht[i] - lft[i];
  }
  cout << ans << endl;
}
