#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 5;
struct node {
  int val, id;
} a[N];
int n;
int dp[N * N], tree[N], ranks[N];
inline int lowbit(int x) { return x & -x; }
inline int query(int x) {
  int sum = 0;
  while (x != 0) {
    sum += tree[x];
    x -= lowbit(x);
  }
  return sum;
}
inline void update(int x, int v) {
  while (x <= n) {
    tree[x] += v;
    x += lowbit(x);
  }
  return;
}
bool cmp(node a, node b) {
  if (a.val == b.val) return a.id < b.id;
  return a.val < b.val;
}
signed main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].val;
    a[i].id = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    ranks[a[i].id] = i;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (i - 1) - query(ranks[i]);
    update(ranks[i], 1);
  }
  printf("%.6lf", (double)(2 * ans - (ans & 1)));
  return 0;
}
