#include <bits/stdc++.h>
using namespace std;
const int MAX = 100001;
const long long mod = 1000 * 1000 * 1000 + 7;
int main() {
  int n;
  while (cin >> n) {
    int arr[3002];
    for (int i = 0; i < n; i++) cin >> arr[i];
    double ans = 0;
    bool is = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n - 1; j++) {
        if (arr[j] > arr[j + 1]) swap(arr[j], arr[j + 1]), ans = ans + 1.0;
      }
    }
    int k = ans;
    ans *= 2;
    if (k % 2) ans--;
    printf("%.6f\n", ans);
  }
  return 0;
}
