#include <bits/stdc++.h>
using namespace std;
int p[3010];
int main(void) {
  int N, i, j;
  cin >> N;
  for ((i) = 0; (i) < (int)(N); (i)++) cin >> p[i];
  int cnt = 0;
  for ((i) = 0; (i) < (int)(N); (i)++)
    for (j = i + 1; j < N; j++)
      if (p[i] > p[j]) cnt++;
  int ans = cnt * 2;
  if (cnt % 2 == 1) ans--;
  cout << ans << endl;
  return 0;
}
