#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 0;
  double a[3010];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i] > a[j]) cnt++;
    }
  }
  if (cnt % 2 == 0)
    printf("%f\n", (double)(cnt * 2));
  else
    printf("%f\n", double(cnt / 2 * 4 + 1));
  return 0;
}
