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