#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
struct Edge {
  int from, to, w;
} edges[maxn];
int val[maxn];
long long ans;
int size[maxn], fa[maxn];
bool cmp(Edge a, Edge b) { return a.w > b.w; }
int Getfa(int x) {
  if (fa[x] == x)
    return x;
  else
    return fa[x] = Getfa(fa[x]);
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) scanf("%d", &val[i]);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    edges[i].from = u, edges[i].to = v;
    edges[i].w = min(val[u], val[v]);
  }
  sort(edges + 1, edges + 1 + m, cmp);
  for (int i = 1; i <= n; ++i) size[i] = 1, fa[i] = i;
  ans = 0;
  for (int i = 1; i <= m; ++i) {
    int u = edges[i].from, v = edges[i].to;
    int fx = Getfa(u), fy = Getfa(v);
    if (fx == fy) continue;
    ans += (long long)size[fx] * size[fy] * edges[i].w;
    fa[fx] = fy;
    size[fy] += size[fx];
  }
  printf("%.6lf\n", (double)2.0 * ans / n / (n - 1));
  return 0;
}
