#include <bits/stdc++.h>
double r, k, f[1000005], i, n, x;
int main() {
  for (scanf("%lf", &n); ++i <= n;
       scanf("%lf", &x), r += (k += i - f[(int)x]), f[(int)x] = i)
    ;
  printf("%f", (r * 2 - n) / (1LL * n * n));
}
