#include <bits/stdc++.h>
using namespace std;
int n;
int arr[30000];
int main() {
  scanf("%d ", &n);
  for (int i = 0; i < n; i++) scanf("%d ", &arr[i]);
  int c = 0;
  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++)
      if (arr[i] > arr[j]) c++;
  int c0 = 0;
  int c1 = 1, c2 = (c == 0) ? 0 : 1;
  for (int i = 2; i <= c; i++) {
    c2 = 4 + c0;
    c0 = c1;
    c1 = c2;
  }
  cout << c2 << endl;
}
