#include <bits/stdc++.h>
using namespace std;
int N[3002], n;
int main() {
  scanf("%d", &n);
  for (int ix = 1; ix <= n; ix++) scanf("%d", &N[ix]);
  int res = 0;
  for (int ix1 = 1; ix1 <= n; ix1++)
    for (int ix2 = ix1 + 1; ix2 <= n; ix2++)
      if (N[ix1] > N[ix2]) res++;
  if (res == 0)
    cout << 0.0 << endl;
  else {
    int ans = 0;
    if (res % 2) {
      ans++;
      res--;
    }
    ans += res * 2;
    cout << ans << endl;
  }
}
