#include <bits/stdc++.h>
using namespace std;
const int mxn = 1000010;
int i, j, k, x, y, z;
long long lx, ly, lz;
int m, n, p;
int a[mxn];
int prv[mxn];
int f[mxn];
long long s;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    f[i] = prv[a[i]] + 1;
    prv[a[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    s += (long long)(i - f[i] + 1) * (n - i + 1) * 2 - 1;
  }
  printf("%.15lf\n", (double)s / ((long long)n * n));
  return 0;
}
