#include <bits/stdc++.h>
using namespace std;
int cnt;
int seq[3333];
int n;
int insert_sort() {
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j > 0 && seq[j - 1] > seq[j]) {
      swap(seq[j - 1], seq[j]);
      cnt++;
      j--;
    }
  }
  return cnt;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &seq[i]);
  int cnt = insert_sort();
  if (cnt % 2 == 0) {
    printf("%lf\n", (double)(2 * cnt));
  } else {
    printf("%lf\n", (double)(2 * (cnt - 1) + 1));
  }
  return 0;
}
