Problem: You are given an array a consisting of n positive integers. You pick two integer numbers l and r from 1 to n, inclusive (numbers are picked randomly, equiprobably and independently). If l > r, then you swap values of l and r. You have to calculate the expected value of the number of unique elements in segment of the array from index l to index r, inclusive (1-indexed).

Input

The first line contains one integer number n (1 ≤ n ≤ 106). The second line contains n integer numbers a1, a2, ... an (1 ≤ ai ≤ 106) — elements of the array.

Output

Print one number — the expected number of unique elements in chosen segment. 

Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 4 — formally, the answer is correct if <image>, where x is jury's answer, and y is your answer.

Examples

Input

2
1 2


Output

1.500000


Input

2
2 2


Output

1.000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 123;
const long long LINF = (long long)1e18 + 123;
const long double EPS = (long double)1e-8;
const long long MOD = (long long)1e9 + 7;
long long power(long long x, long long y, long long mod = MOD) {
  if (y == 0) {
    return 1;
  }
  if (y & 1) {
    return power(x, y - 1, mod) * x % mod;
  } else {
    long long tmp = power(x, y / 2, mod);
    return tmp * tmp % mod;
  }
}
inline void add(long long &x, long long y, long long mod = MOD) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
}
inline long long sum(long long x, long long y, long long mod = MOD) {
  add(x, y, mod);
  return x;
}
inline long long mult(long long x, long long y, long long mod = MOD) {
  return (x * y) % mod;
}
inline long long div(long long x, long long y, long long mod) {
  return x * power(y, mod - 2, mod);
}
template <typename A, typename B>
inline bool mini(A &x, const B &y) {
  if (y < x) {
    x = y;
    return true;
  }
  return false;
}
template <typename A, typename B>
inline bool maxi(A &x, const B &y) {
  if (y > x) {
    x = y;
    return true;
  }
  return false;
}
template <typename T>
inline void read(T first, T last) {
  while (first != last) {
    cin >> *(first++);
  }
}
template <typename T>
inline void print(T first, T last) {
  while (first != last) {
    cout << *(first++) << " ";
  }
  cout << "\n";
}
void run();
int main() {
  if (strlen("")) {
    freopen(
        ""
        ".in",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  }
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);
  run();
  return 0;
}
const int N = (int)1e6 + 123;
int n;
int a[N];
vector<int> p[N];
long long f(long long k) { return k * (k + 1) / 2; }
void run() {
  cin >> n;
  for (auto i = 0; i < N; i++) p[i].push_back(0);
  for (auto i = 1; i < n + 1; i++) {
    cin >> a[i];
    p[a[i]].push_back(i);
  }
  for (auto i = 0; i < N; i++) p[i].push_back(n + 1);
  long double sum = -n;
  for (auto v = 0; v < N; v++) {
    if ((int)(p[v]).size() == 2) continue;
    sum += 2 * f(n);
    for (auto i = 0; i < (int)(p[v]).size() - 1; i++) {
      int l = p[v][i];
      int r = p[v][i + 1];
      int len = r - l - 1;
      sum -= 2 * f(len);
    }
  }
  cout << (sum / ((long double)n * n)) << "\n";
}