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;
pair<long long, int> operator+(pair<long long, int> a, pair<long long, int> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
struct segmentTree {
  vector<pair<long long, int> > t;
  segmentTree(int n) { t.resize(4 * n + 7); }
  void change(int v, int tl, int tr, int pos, pair<long long, int> val) {
    if (tl == tr) {
      t[v] = val;
    } else {
      int tm = (tl + tr) / 2;
      if (pos <= tm) {
        change(2 * v, tl, tm, pos, val);
      } else {
        change(2 * v + 1, tm + 1, tr, pos, val);
      }
      t[v] = t[2 * v] + t[2 * v + 1];
    }
  }
  pair<long long, int> getSum(int v, int tl, int tr, int l, int r) {
    if (r < tl || l > tr) return make_pair(0, 0);
    if (tl >= l && tr <= r) return t[v];
    int tm = (tl + tr) / 2;
    return getSum(2 * v, tl, tm, l, r) + getSum(2 * v + 1, tm + 1, tr, l, r);
  }
};
int main() {
  int n;
  scanf("%d", &n);
  segmentTree st(n + 1);
  double res = 0;
  long long total = 1LL * n * (n + 1) / 2;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    pair<long long, int> go1 = st.getSum(1, 1, n, x, n);
    pair<long long, int> go2 = st.getSum(1, 1, n, 1, x);
    long long ways1 = 1LL * (n - i + 1) * go1.first;
    double prob1 = 1.0 * ways1 / total;
    res += prob1 * 0.5;
    double prob2 = 1.0 * go1.second - prob1;
    res += prob2;
    long long ways2 = 1LL * (n - i + 1) * go2.first;
    double prob3 = 1.0 * ways2 / total;
    res += prob3 * 0.5;
    st.change(1, 1, n, x, make_pair(i, 1));
  }
  printf("%.20lf\n", res);
}