#include <bits/stdc++.h>
using namespace std;
int f[4000], n;
inline int lowbit(int t) { return t & -t; }
int get(int t) {
  int ans = 0;
  while (t != 0) {
    ans += f[t];
    t -= lowbit(t);
  }
  return ans;
}
void change(int t) {
  while (t <= n) {
    f[t]++;
    t += lowbit(t);
  }
}
int main() {
  int num = 0, x;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    num += i - get(x);
    change(x);
  }
  if (num <= 1) {
    if (num == 0) printf("0.000000\n");
    if (num == 1) printf("1.000000\n");
  } else {
    double ans = num % 2;
    num -= num % 2;
    ans += num + num;
    printf("%.6lf\n", ans);
  }
}
