#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
int n, a, z = 0;
double ans[9000000];
vector<int> p;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    p.push_back(a);
  }
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= 0; j--) {
      if (p[j] > p[i]) {
        z++;
      }
    }
  }
  ans[0] = 0;
  ans[1] = 1;
  for (int i = 2; i <= z; i++) {
    ans[i] = ans[i - 2] + 4;
  }
  printf("%.3f", ans[z]);
}
