#include <bits/stdc++.h>
using namespace std;
const int64_t M = 1e9 + 7, N = 1e6 + 5;
int64_t ind[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  int64_t n;
  double ans = 0;
  cin >> n;
  for (int64_t i = 1; i <= n; i++) {
    int64_t x;
    cin >> x;
    ans += 2 * (i - ind[x]) * (n - i + 1) - 1, ind[x] = i;
  }
  ans /= n, ans /= n;
  cout << ans;
}
