#include <bits/stdc++.h>
using namespace std;
int n, m, par[111111];
long long cnt[111111], v[111111];
struct edge {
  int l, r;
  long long w;
} e[111111];
bool cmp(edge a, edge b) { return a.w > b.w; }
int find(int x) {
  if (par[x] != x) par[x] = find(par[x]);
  return par[x];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= (n); i++) par[i] = i, cnt[i] = 1;
  for (int i = 1; i <= n; i++) scanf("%I64d", &v[i]);
  int x, y;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &e[i].l, &e[i].r);
    e[i].w = min(v[e[i].l], v[e[i].r]);
  }
  sort(e, e + m, cmp);
  long long sum = 0;
  for (int i = 0; i < m; i++) {
    x = find(e[i].l);
    y = find(e[i].r);
    if (x != y) {
      sum += cnt[x] * cnt[y] * e[i].w;
      par[x] = y;
      cnt[y] += cnt[x];
    }
  }
  double ans = 1.0 * sum / ((long long)n * (n - 1) / 2);
  printf("%.6f\n", ans);
}
