#include <bits/stdc++.h>
using namespace std;
vector<long long> a(1000006, 0);
vector<long long> last_occurence(1000006, 0);
vector<long long> unique_elements(1000006, 0);
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  double sum = 0.0;
  for (long long i = 1; i <= n; i++) {
    unique_elements[i] = unique_elements[i - 1] + (i - last_occurence[a[i]]);
    last_occurence[a[i]] = i;
    sum += unique_elements[i];
  }
  double res = 0.0;
  res = (2 * sum - n) / (n * n);
  cout << res << endl;
  return 0;
}
