#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
int main() {
  int n, i, j;
  static int c[N];
  scanf("%d", &n);
  long long cnt = 0;
  for (i = 1; i <= n; ++i) {
    scanf("%d", &j);
    cnt += 1LL * (i - c[j]) * (n + 1 - i);
    c[j] = i;
  }
  cnt = 2 * cnt - n;
  double ans = (double)cnt / (1LL * n * n);
  printf("%.6lf\n", ans);
}
