#include <bits/stdc++.h>
using namespace std;
const int N = 1000001;
vector<int> L[N];
double n2(long long int n) { return n * n; }
int main() {
  long long int n;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    L[ai].push_back(i);
  }
  double ans = 0;
  for (int i = 1; i < N; i++) {
    if (L[i].size()) {
      L[i].push_back(n);
      double curr = 0.0;
      int last = -1;
      for (int j = 0; j < L[i].size(); j++) {
        curr += n2(L[i][j] - last - 1);
        last = L[i][j];
      }
      ans += 1.0 - (curr / n2(n));
    }
  }
  printf("%0.9lf\n", ans);
  return 0;
}
