include <bits/stdc++.h>
define N 2005
using namespace std;
int n;
int a[N];
int ans;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
a[i] = abs(a[i]);
}
for (int i = 1; i <= n; i++) {
int a1 = 0, a2 = 0;
for (int j = 1; j < i; j++) a1 += a[j] < a[i];
for (int j = n; j > i; j--) a2 += a[j] < a[i];
ans += min(a1, a2);
}
cout << ans << '\n';
return 0;
}