Problem: You are given a permutation of integers from 1 to n. Exactly once you apply the following operation to this permutation: pick a random segment and shuffle its elements. Formally:

  1. Pick a random segment (continuous subsequence) from l to r. All <image> segments are equiprobable. 
  2. Let k = r - l + 1, i.e. the length of the chosen segment. Pick a random permutation of integers from 1 to k, p1, p2, ..., pk. All k! permutation are equiprobable. 
  3. This permutation is applied to elements of the chosen segment, i.e. permutation a1, a2, ..., al - 1, al, al + 1, ..., ar - 1, ar, ar + 1, ..., an is transformed to a1, a2, ..., al - 1, al - 1 + p1, al - 1 + p2, ..., al - 1 + pk - 1, al - 1 + pk, ar + 1, ..., an. 



Inversion if a pair of elements (not necessary neighbouring) with the wrong relative order. In other words, the number of inversion is equal to the number of pairs (i, j) such that i < j and ai > aj. Find the expected number of inversions after we apply exactly one operation mentioned above.

Input

The first line contains a single integer n (1 ≤ n ≤ 100 000) — the length of the permutation.

The second line contains n distinct integers from 1 to n — elements of the permutation.

Output

Print one real value — the expected number of inversions. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 9. 

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.

Example

Input

3
2 3 1


Output

1.916666666666666666666666666667

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct node {
  ll value, position, y;
  node *left, *right;
  ll cnt, sum, sumsq;
  node(ll value, ll position)
      : value(value),
        position(position),
        y(rand()),
        left(NULL),
        right(NULL),
        sum(position),
        sumsq(position * position) {}
};
typedef node *tree;
ll cnt(tree &t) { return t ? t->cnt : 0; }
ll sum(tree &t) { return t ? t->sum : 0; }
ll sumsq(tree &t) { return t ? t->sumsq : 0; }
void upd(tree &t) {
  if (!t) return;
  t->cnt = 1 + cnt(t->left) + cnt(t->right);
  t->sum = t->position + sum(t->left) + sum(t->right);
  t->sumsq = t->position * t->position + sumsq(t->left) + sumsq(t->right);
}
void split(tree t, ll x, tree &l, tree &r) {
  upd(t);
  if (t == NULL) {
    l = r = NULL;
    return;
  }
  if (t->value < x) {
    split(t->right, x, t->right, r);
    l = t;
  } else {
    split(t->left, x, l, t->left);
    r = t;
  }
  upd(l);
  upd(r);
}
void merge(tree l, tree r, tree &t) {
  upd(l);
  upd(r);
  if (!l) {
    t = r;
    return;
  }
  if (!r) {
    t = l;
    return;
  }
  if (l->y < r->y) {
    merge(l, r->left, r->left);
    t = r;
  } else {
    merge(l->right, r, l->right);
    t = l;
  }
  upd(t);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll intervals = (ll)n * (n + 1) / 2;
  tree t = NULL;
  double ans_outside = 0, ans_inside = 0, ans_left = 0, ans_right = 0,
         ans_prefix = 0, ans_suffix = 0, ans = 0;
  for (ll y = 0; y < n; ++y) {
    tree t1, t2;
    split(t, a[y], t1, t2);
    ans_outside += double((y * y * cnt(t2) + sumsq(t2) - 2 * y * sum(t2) -
                           y * cnt(t2) + sum(t2)) /
                          2);
    ans_left +=
        double(y * n * cnt(t2) - n * sum(t2) - y * y * cnt(t2) + sum(t2) * y);
    ans_right += double(y * cnt(t2) - sum(t2) + y * sum(t2) - sumsq(t2));
    ans_suffix += double((sumsq(t2) + sum(t2)) / 2);
    ans_prefix += double((ll)(n - y - 1) * (ll)(n - y) * cnt(t2) / 2);
    merge(t1, new node(a[y], y), t);
    merge(t, t2, t);
  }
  for (ll len = 1; len <= n; ++len) {
    double perms = (len * (len - 1) / 2) / 2.0;
    ans_inside += perms * (n - len + 1);
  }
  cerr << "Inside: " << ans_inside << endl;
  cerr << "Outside: " << ans_outside << endl;
  cerr << "Left: " << ans_left << endl;
  cerr << "Right: " << ans_right << endl;
  cerr << "Prefix: " << ans_prefix << endl;
  cerr << "Suffix: " << ans_suffix << endl;
  ans =
      ans_outside + ans_inside + ans_left + ans_right + ans_prefix + ans_suffix;
  ans /= intervals;
  cout.precision(12);
  cout << fixed;
  cout << ans;
  return 0;
}