#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5, M = 9e6 + 5;
int n;
int arr[N];
double dp[M];
double solve(int moves, int prec) {
  if (moves <= 0) return prec;
  if (prec == 26) {
    return prec;
  }
  double &ret = dp[moves];
  if (ret == ret) return ret;
  ret = 2 + 0.5 * solve(moves, prec + 1) + 0.5 * solve(moves - 2, prec + 1);
  return ret;
}
int main() {
  memset(dp, -1, sizeof dp);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", arr + i);
  }
  int comp = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = n - 2; j >= i; --j) {
      if (arr[j] > arr[j + 1]) {
        ++comp;
        swap(arr[j], arr[j + 1]);
      }
    }
  }
  if (comp % 2)
    printf("%d\n", comp * 2 - 1);
  else
    printf("%d\n", comp * 2);
}
