#include <bits/stdc++.h>
const int N = 3005;
int n, a[N], bit[N], cnt;
void add(int x, int val) {
  for (; x <= n; x += x & -x) bit[x] += val;
}
int query(int x) {
  int res = 0;
  for (; x; x -= x & -x) res += bit[x];
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = n; i >= 1; --i) {
    cnt += query(a[i] - 1);
    add(a[i], 1);
  }
  printf("%d.000000\n", (cnt << 1) - (cnt & 1));
  return 0;
}
