#include <bits/stdc++.h>
inline int getInt() {
  int s;
  scanf("%d", &s);
  return s;
}
using namespace std;
int count(vector<int> p) {
  const int n = p.size();
  int ret = 0;
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < n - i - 1; j++) {
      if (p[j] > p[j + 1]) {
        ret++;
        swap(p[j], p[j + 1]);
      }
    }
  }
  return ret;
}
int main() {
  const int n = getInt();
  vector<int> p(n);
  for (int i = 0; i < (int)(n); i++) p[i] = getInt();
  const int need = count(p);
  printf("%.8f\n", (double)(need % 2 + 4 * (need / 2)));
  return 0;
}
