#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool op = false;
  char c = getchar();
  while (!isdigit(c)) op |= (c == '-'), c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return op ? -x : x;
}
const int N = 3010;
int n;
int a[N];
int main() {
  n = read();
  int res = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    for (int j = 1; j < i; j++)
      if (a[j] > a[i]) res++;
  }
  if (res % 2 == 0)
    printf("%.6lf", 2.0 * res);
  else
    printf("%.6lf", 2.0 * res - 1);
  return 0;
}
