#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
int n, a[10008];
int s;
struct Tprogram {
  void open() {
    freopen("", "r", stdin);
    freopen("", "w", stdout);
  }
  void close() {
    fclose(stdin);
    fclose(stdout);
  }
  void init() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  }
  void work() {
    for (int i = 1; i <= n; i++)
      for (int j = i + 1; j <= n; j++)
        if (a[i] > a[j]) s++;
    s--;
    if (s < 0)
      printf("0.000000\n");
    else if (s & 1 ^ 1)
      printf("%lf\n", (double)4 * s / 2 + 1);
    else
      printf("%lf\n", ((double)s - 1) / 2 * 4 + 4);
  }
} Program;
int main() {
  Program.init();
  Program.work();
  Program.close();
  return 0;
}
