#include <bits/stdc++.h>
using namespace std;
__inline bool nextInt(int &val) {
  char ch;
  int sgn = 1;
  while ((ch = getchar()) != EOF) {
    if (ch == '-') sgn = -1;
    if (ch >= '0' && ch <= '9') break;
  }
  if (ch == EOF) return false;
  val = (int)(ch - '0');
  while (true) {
    ch = getchar();
    if (ch >= '0' && ch <= '9') {
      val = 10 * val + (int)(ch - '0');
    } else
      break;
  }
  val *= sgn;
  return true;
}
__inline bool nextString(string &s) {
  char ch;
  while ((ch = getchar()) != EOF) {
    if (ch >= 33 && ch <= 126) break;
  }
  if (ch == EOF) return false;
  s = string(1, ch);
  while (true) {
    ch = getchar();
    if (ch >= 33 && ch <= 126) {
      s = s + string(1, ch);
    } else
      break;
  }
  return true;
}
int n, tmp[3888], p[3888];
int count_inversions(int *p, int l, int r) {
  if (l >= r) return 0;
  int mid = l + ((r - l) >> 1);
  int ret = count_inversions(p, l, mid) + count_inversions(p, mid + 1, r);
  int it = l, il, ir;
  for (il = l, ir = mid + 1; il <= mid && ir <= r;) {
    if (p[il] > p[ir]) {
      tmp[it++] = p[ir++];
    } else {
      ret += (ir - mid - 1);
      tmp[it++] = p[il++];
    }
  }
  for (; il <= mid;) {
    ret += (r - mid);
    tmp[it++] = p[il++];
  }
  for (; ir <= r;) {
    tmp[it++] = p[ir++];
  }
  for (int i = (l); i < (r + 1); i++) p[i] = tmp[i];
  return ret;
}
int brute() {
  int ret = 0;
  for (int i = 0; i < (n); i++)
    for (int j = (i + 1); j < (n); j++)
      if (p[i] > p[j]) ret++;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) scanf("%d", p + i);
  int numInversions = count_inversions(p, 0, n - 1);
  double ret = 4 * (numInversions / 2) + (numInversions % 2);
  printf("%.12lf\n", ret);
  return 0;
}
