#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long count[n];
  count[0] = 1;
  map<long long, long long> m;
  m[arr[0]] = 0;
  for (int i = 1; i < n; i++) {
    if (m.count(arr[i]) > 0) {
      count[i] = count[i - 1] + (i - m[arr[i]]);
      m[arr[i]] = i;
      continue;
    }
    count[i] = count[i - 1] + i + 1;
    m[arr[i]] = i;
  }
  long double sum = 0;
  for (int i = 0; i < n; i++) sum += count[i];
  cout << fixed << setprecision(6) << (2 * sum - n) / (n * n) << endl;
}
