#include <bits/stdc++.h>
using namespace std;
const int N = 3003;
int tree[N];
void update(int i, int val) {
  while (i < N) {
    tree[i] += val;
    i += i & (-i);
  }
}
int get(int i) {
  int res = 0;
  while (i) {
    res += tree[i];
    i -= i & (-i);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int inversions = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    inversions += i - get(x) - 1;
    update(x, 1);
  }
  double ans = 0;
  if (inversions % 2 == 1) {
    ans = inversions * 2 - 1;
  } else
    ans = inversions * 2;
  printf("%.6f", ans);
}
