#include <bits/stdc++.h>
using namespace std;
long long int a[1000006];
long long int last_occurence[1000006];
long long int ans[1000006];
int main() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  memset(last_occurence, 0, sizeof last_occurence);
  memset(ans, 0, sizeof ans);
  double sum = 0.0;
  for (long long int i = 1; i <= n; i++) {
    ans[i] = ans[i - 1] + (i - last_occurence[a[i]]);
    last_occurence[a[i]] = i;
    sum += ans[i];
  }
  double ansr = (2 * sum - n) / (n * n * 1.0);
  cout << fixed << setprecision(6) << ansr << "\n";
}
