#include <bits/stdc++.h>
using namespace std;
int A[3000], tree[3001] = {0}, n, ans = 0;
int read(int idx) {
  int sum = 0;
  while (idx > 0) {
    sum += tree[idx];
    idx -= idx & -idx;
  }
  return sum;
}
void upd(int idx, int val) {
  while (idx <= n) {
    tree[idx] += val;
    idx += idx & -idx;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    ans += read(A[i]);
    upd(A[i], 1);
  }
  if (ans % 2 == 0) {
    ans *= 2;
  } else {
    ans *= 2;
    ans--;
  }
  printf("%d\n", ans);
  return 0;
}
