#include <bits/stdc++.h>
using namespace std;
long long int A[10000000] = {0};
long long int ans[10000000] = {0};
long long int lastoccur[10000000] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int A[n];
  for (long long int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  float sum = 0;
  ans[0] = 0;
  for (int i = 1; i <= n; i++) {
    ans[i] = ans[i - 1] + ((i)-lastoccur[A[i]]);
    sum += ans[i];
    lastoccur[A[i]] = i;
  }
  cout << fixed << setprecision(6) << (((2 * sum) - n) / (n * n)) << endl;
  return 0;
}
