#include <bits/stdc++.h>
using namespace std;
struct node {
  int u, v, w;
  bool operator<(const node &b) const { return w > b.w; }
} edge[100010];
int fa[100010], num[100010], a[100010];
int find(int x) {
  if (fa[x] == x)
    return fa[x];
  else
    return fa[x] = find(fa[x]);
}
int main() {
  int n, m, i, u, v, x, y;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &edge[i].u, &edge[i].v);
    edge[i].w = min(a[edge[i].u], a[edge[i].v]);
  }
  sort(edge + 1, edge + 1 + m);
  for (i = 1; i <= n; i++) {
    fa[i] = i;
    num[i] = 1;
  }
  double tot = 0.0;
  for (i = 1; i <= m; i++) {
    u = edge[i].u;
    v = edge[i].v;
    x = find(u);
    y = find(v);
    if (x == y) continue;
    tot = tot + 1.0 * num[x] * num[y] * edge[i].w;
    fa[x] = y;
    num[y] += num[x];
  }
  double fuck = 1.0 * n * (n - 1) / 2;
  printf("%.10f\n", tot / fuck);
  return 0;
}
