#include <bits/stdc++.h>
using namespace std;
int n, m;
struct rec {
  int x, y, w;
} e[110000];
int a[110000], f[110000], s[110000];
double ans = 0;
bool cmp(rec a, rec b) { return a.w > b.w; }
int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) f[i] = i, s[i] = 1;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++)
    scanf("%d%d", &e[i].x, &e[i].y), e[i].w = min(a[e[i].x], a[e[i].y]);
  sort(e + 1, e + m + 1, cmp);
  for (int i = 1; i <= m; i++) {
    int fx = find(e[i].x), fy = find(e[i].y);
    if (fx != fy) {
      ans += (double)s[fx] * (double)s[fy] * (double)e[i].w * (double)2;
      s[fx] += s[fy];
      s[fy] = 0;
      f[fy] = fx;
    }
  }
  ans /= n;
  ans /= n - 1;
  printf("%.6lf\n", ans);
  return 0;
}
