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