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;
int a[100010];
long long int bit[100010], bt2[100010];
void upd(int ind, int val) {
  while (ind < 100010) {
    bit[ind] += val;
    ind += ind & (-ind);
  }
}
long long int query(int ind) {
  long long int res = 0LL;
  while (ind) {
    res += bit[ind];
    ind -= ind & (-ind);
  }
  return res;
}
void upd2(int ind, int val) {
  while (ind < 100010) {
    bt2[ind] += val;
    ind += ind & (-ind);
  }
}
long long int query2(int ind) {
  long long int res = 0LL;
  while (ind) {
    res += bt2[ind];
    ind -= ind & (-ind);
  }
  return res;
}
void reset() {
  for (int i = 0; i < 100010; i++) {
    bit[i] = 0;
  }
}
long double getprob(int l, int r, int n) {
  long long int t = 1LL * l * (n - r + 1);
  return t;
}
long double divs(long long int x, long long int y) {
  return (long double)x / (long double)y;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  long double ans = 0.000;
  long long int tt = 1LL * n * (n + 1);
  long long int res = 0LL;
  long double sj = 0.000;
  for (int i = 1; i <= n; i++) {
    long long int t = query(a[i]);
    ans += 1LL * t * (n + 1 - i);
    sj += divs(1LL * t * (n + 1 - i), 1LL * n * (n + 1));
    upd(a[i], i);
  }
  reset();
  for (int i = 1; i <= n; i++) {
    long long int count = query2(n) - query2(a[i] - 1);
    long long int sum = query(n) - query(a[i] - 1);
    sj += (long double)count - divs(1LL * sum * (n + 1 - i), 1LL * n * (n + 1));
    ;
    upd(a[i], i);
    upd2(a[i], 1);
  }
  cout << setprecision(20) << sj << endl;
}