#include <bits/stdc++.h>
using namespace std;
int P[3001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> P[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      cnt += (P[j] < P[i]);
    }
  }
  int sol = 4 * (cnt / 2) + cnt % 2;
  cout << sol << endl;
  return 0;
}
