#include <bits/stdc++.h>
using namespace std;
int a[3009];
double dp[3009][3009];
double memoize(int inv, int moves) {
  if (inv <= 1) return double(inv + moves);
  if (moves >= 3000) return moves;
  if (dp[inv][moves] != -1) return dp[inv][moves];
  double ans = 0.0000;
  ans += 0.5 * memoize(inv - 2, moves + 2);
  ans += 0.5 * memoize(inv, moves + 2);
  return dp[inv][moves] = ans;
}
int main() {
  for (int i = int(0); i <= int(3000); i++)
    for (int j = int(0); j <= int(3000); j++) dp[i][j] = -1.00;
  int n;
  scanf("%d", &n);
  for (int i = int(0); i <= int(n - 1); i++) scanf("%d", &a[i]);
  int invcount = 0;
  for (int i = int(0); i <= int(n - 1); i++) {
    for (int j = int(i + 1); j <= int(n - 1); j++) {
      if (a[i] > a[j]) invcount++;
    }
  }
  if (invcount % 2 == 0)
    printf("%d\n", 2 * invcount);
  else
    printf("%d\n", 2 * invcount - 1);
  return 0;
}
