#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int MAXM = 2e5 + 10;
int n, m;
int pre[MAXN], size[MAXN];
int ord[MAXN], val[MAXN];
int frst[MAXN], nxt[MAXM], ed[MAXM];
bool vis[MAXN];
void add(int a, int b) {
  nxt[++m] = frst[a];
  frst[a] = m;
  ed[m] = b;
}
bool cmp(int a, int b) { return val[a] > val[b]; }
int find(int x) {
  int r = pre[x];
  while (pre[r] != r) r = pre[r];
  while (pre[x] != r) {
    int t = pre[x];
    pre[x] = r;
    x = t;
  }
  return r;
}
int main() {
  int e0;
  m = 0;
  memset(frst, -1, sizeof(frst));
  scanf("%d%d", &n, &e0);
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]), ord[i] = i;
  sort(ord + 1, ord + n + 1, cmp);
  for (int i = 1; i <= e0; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    add(a, b), add(b, a);
  }
  for (int i = 1; i <= n; i++) pre[i] = i, size[i] = 1;
  memset(vis, false, sizeof(vis));
  long long ans = 0;
  for (int i = 1, x = ord[i]; i <= n; x = ord[++i]) {
    for (int r = frst[x], y = ed[r]; r != -1; y = ed[r = nxt[r]])
      if (vis[y]) {
        int fx = find(x), fy = find(y);
        if (fx != fy) {
          ans += (long long)size[fx] * size[fy] * val[x];
          pre[fx] = fy;
          size[fy] += size[fx];
        }
      }
    vis[x] = true;
  }
  printf("%lf\n", (double)ans / ((double)n * (n - 1) / 2));
}
