#include <bits/stdc++.h>
using namespace std;
int n, a[3005], t[3005];
int msort(int l, int r) {
  if (l == r) return 0;
  int m = l + r >> 1;
  int t1 = msort(l, m);
  int t2 = msort(m + 1, r);
  int t3 = 0;
  int i = l, j = m + 1, k = l;
  while (i <= m && j <= r) {
    if (a[i] > a[j]) {
      t3 += m - i + 1;
      t[k++] = a[j++];
    } else {
      t[k++] = a[i++];
    }
  }
  while (i <= m) t[k++] = a[i++];
  while (j <= r) t[k++] = a[j++];
  for (int p = l; p <= r; p++) a[p] = t[p];
  return t1 + t2 + t3;
}
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int nd = msort(1, n);
  if (nd & 1) {
    printf("%lf", (double)(2 * nd - 1));
  } else
    printf("%lf", (double)2 * nd);
}
int main() {
  init();
  return 0;
}
