#include <cstdio>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)
typedef long long ll;
const int maxn = 1000005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
int a[maxn],pre[maxn];
int main()
{
    int n,x;
    while(~scanf("%d",&n))
    {
        mst(pre,0);
        ll ans=0;
        ll temp=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&x);
            temp+=i-pre[x];
            pre[x]=i;
            ans+=(ll)temp*2-1;
        }
        printf("%.6f\n",ans*1.0/n/n);
    }
    return 0;
}