#include <bits/stdc++.h>
using namespace std;
vector<int> mainVect;
int n;
vector<vector<int>> v;
void input() {
  cin >> n;
  int a;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    mainVect.push_back(a);
  }
}
int bubbleSort() {
  int ans = 0;
  for (int i = 0; i < mainVect.size(); ++i) {
    int now = 0;
    for (int i = 0; i < mainVect.size() - 1; ++i) {
      if (mainVect[i] > mainVect[i + 1]) {
        now++;
        ans++;
        swap(mainVect[i], mainVect[i + 1]);
      }
    }
    if (now == 0) break;
  }
  return ans;
}
double solve() {
  int ans = bubbleSort();
  if (ans == 0) return 0;
  ans = 1 + 4 * ((ans - 1) / 2) + 3 * ((ans - 1) % 2);
  return ans;
}
void output(double ans) { cout << fixed << setprecision(10) << ans; }
int main() {
  input();
  double ans = solve();
  output(ans);
  return 0;
}
