#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int p[N];
double ans[N * N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  int t = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      if (p[j] > p[i]) t++;
    }
  }
  ans[0] = 0, ans[1] = 1;
  for (int i = 2; i <= t; i++) ans[i] = 4 + ans[i - 2];
  printf("%f\n", ans[t]);
  return 0;
}
