#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
const double inf = ~0u >> 2;
int fa[100010], res[100010], a[100010];
int find(int x) {
  if (fa[x] != x) {
    fa[x] = find(fa[x]);
    return fa[x];
  }
  return x;
}
struct node {
  int u, v, w;
} p[100010];
bool cmp(node a, node b) { return a.w > b.w; }
int main() {
  int n, m, i;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    fa[i] = i;
    res[i] = 1;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &p[i].u, &p[i].v);
    p[i].w = min(a[p[i].u], a[p[i].v]);
  }
  sort(p + 1, p + m + 1, cmp);
  double ans = 0;
  for (i = 1; i <= m; i++) {
    int tx = find(p[i].u), ty = find(p[i].v);
    if (tx != ty) {
      fa[tx] = ty;
      ans += (double)p[i].w * res[tx] * res[ty];
      res[ty] += res[tx];
    }
  }
  printf("%.6f\n", (ans * 2) / (n * 1.0 * (n - 1)));
  return 0;
}
