#include <bits/stdc++.h>
using namespace std;
double get(long long n) {
  if (n < 1) return 0;
  return double(n * n);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long N = 1e6 + 1;
  vector<vector<long long>> v(N + 1);
  for (long long i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    v[a].push_back(i + 1);
  }
  double long ans = 0;
  for (long long i = 1; i < N; ++i) {
    if (v[i].empty()) continue;
    long long l = 1;
    double total = 0;
    for (long long j : v[i]) {
      total += get(j - l);
      l = j + 1;
    }
    total += get(n - l + 1);
    ans += 1.0 - (total / (double)(n * n));
  }
  cout << fixed << setprecision(10) << ans;
  return 0;
}
