#include <bits/stdc++.h>
const int maxn = 1000001;
struct F {
  long long N;
  double sum;
  int last[maxn];
  void init() {
    int t;
    scanf("%I64d", &N);
    for (long long i = 1; i <= N; i++) {
      scanf("%d", &t);
      sum += (i - last[t]) * (N - i + 1);
      last[t] = i;
    }
  }
  void work() {
    sum = (sum - N) * 2 + N;
    double now = N * N;
    sum /= now;
    printf("%.6lf\n", sum);
  }
} sol;
int main() {
  sol.init();
  sol.work();
  return 0;
}
