#include <bits/stdc++.h>
using namespace std;
int a[3010];
int main() {
  int n, temp, i, j, ans = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j++) {
      if (a[j] == i) break;
    }
    for (; j > i; j--) {
      temp = a[j];
      a[j] = a[j - 1];
      a[j - 1] = temp;
      ans++;
    }
  }
  if (ans % 2 == 0)
    printf("%.10f\n", 2.0 * ans);
  else
    printf("%.10f\n", 2.0 * ans - 1.0);
  return 0;
}
