#include <bits/stdc++.h>
using namespace std;
double p(int x) {
  if (x == 0) return 0;
  if (x == 1) return 1;
  return 4 + p(x - 2);
}
int num[3100];
int main() {
  int n;
  cin >> n;
  int total = 0;
  for (int i = 0; i < n; ++i) {
    cin >> num[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n - 1; ++j) {
      if (num[j] > num[j + 1]) {
        swap(num[j], num[j + 1]);
        total++;
      }
    }
  }
  printf("%.6f\n", p(total));
  return 0;
}
