#include <bits/stdc++.h>
int a[10000], c[10000];
int n;
long long cnt, k;
void mergesort(int l, int r) {
  int mid, i, j, tmp, q;
  if (r > l + 1) {
    mid = (l + r) / 2;
    mergesort(l, mid - 1);
    mergesort(mid, r);
    tmp = l;
    i = l;
    j = mid;
    while (i < mid && j <= r) {
      if (a[i] > a[j]) {
        c[tmp++] = a[j++];
        cnt += mid - i;
      } else
        c[tmp++] = a[i++];
    }
    if (j <= r) {
      for (; j <= r; ++j) c[tmp++] = a[j];
    } else {
      for (; i < mid; ++i) c[tmp++] = a[i];
    }
    for (i = l; i <= r; ++i) a[i] = c[i];
  } else if (r - l == 1 && a[r] < a[l]) {
    cnt++;
    q = a[r];
    a[r] = a[l];
    a[l] = q;
  }
  return;
}
int main() {
  bool flag;
  int i, j, l, m, q, w, e, r;
  r = 0;
  while (scanf("%d", &n) != EOF) {
    r++;
    cnt = 0;
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    mergesort(1, n);
    double ans;
    if (cnt % 2 == 0)
      ans = 1.0 * cnt * 2;
    else
      ans = 1.0 * cnt * 2 - 1.0;
    printf("%.6f\n", ans);
  }
  return 0;
}
