#include <bits/stdc++.h>
using namespace std;
int count_inversions(vector<int> v) {
  int t = 0;
  for (int i = 0; i < (int)v.size(); ++i)
    for (int j = i + 1; j < (int)v.size(); ++j)
      if (v[i] > v[j]) t++;
  return t;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v(n);
  for (int i = 0; i < n; ++i) scanf("%d", &v[i]);
  int inversions = count_inversions(v);
  cout << (inversions / 2) * 4 + (inversions % 2) << endl;
}
