#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
int N, res, dp[maxn][maxn], upd[maxn][maxn];
vector<int> vals, arr;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    vals.push_back(-abs(a));
    arr.push_back(abs(a));
  }
  sort(vals.begin(), vals.end());
  vals.resize(unique(vals.begin(), vals.end()) - vals.begin());
  for (int ck : vals) {
    vector<int> v;
    ck = -ck;
    for (int i = 1; i <= arr.size(); i++)
      if (arr[i - 1] == ck) v.push_back(i);
    upd[0][0] = ck;
    for (int i = 1; i <= v.size(); i++) {
      int t = v[i - 1];
      for (int n = 0; n <= i; n++) {
        dp[i][n] = 0x3f3f3f3f;
        if (upd[i - 1][n] == ck)
          dp[i][n] = dp[i - 1][n] + N - v[i - 1] - (int)(v.size() - i),
          upd[i][n] = ck;
        if (n && upd[i - 1][n - 1] == ck)
          dp[i][n] = min(dp[i][n], dp[i - 1][n - 1] + v[i - 1] - 1 - (n - 1)),
          upd[i][n] = ck;
      }
    }
    reverse(v.begin(), v.end());
    for (int b : v) arr.erase(arr.begin() + b - 1), N--;
    int mn = 0x3f3f3f3f;
    for (int n = 0; n <= v.size(); n++)
      if (upd[v.size()][n] == ck) mn = min(mn, dp[v.size()][n]);
    res += mn;
  }
  cout << res << '\n';
}
