#include <bits/stdc++.h>
const double eps = (1e-5);
using namespace std;
int dcmp(long double a, long double b) {
  return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
long long getBit(long long num, int idx) { return ((num >> idx) & 1ll) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }
long long flipBit(long long num, int idx) { return num ^ (1ll << idx); }
void M() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int countNumBit1(int mask) {
  int ret = 0;
  while (mask) {
    mask &= (mask - 1);
    ++ret;
  }
  return ret;
}
int arr[3009], E[4500009];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int cnt = 0;
  while (1) {
    int fl = 0;
    for (int i = 0; i < n; i++) {
      if (i + 1 < n && arr[i] > arr[i + 1])
        swap(arr[i], arr[i + 1]), cnt++, fl = 1;
    }
    if (!fl) break;
  }
  E[1] = 1;
  for (int i = 2; i <= cnt; i++) E[i] = 4 + E[i - 2];
  cout << fixed << setprecision(9) << (double)E[cnt] << endl;
}
