#include <bits/stdc++.h>
using namespace std;
struct edge {
  int n1, pp;
} b[300000];
long long v[110000], n, size[110000];
int len, m, a[110000], f[110000], pd[110000], p[110000];
bool cmp(int k1, int k2) { return v[k1] > v[k2]; }
int gf(int k) {
  if (f[k] == k) return f[k];
  return f[k] = gf(f[k]);
}
void ade(int k1, int k2) {
  len++;
  b[len].pp = k2;
  b[len].n1 = p[k1];
  p[k1] = len;
}
void add(int k1, int k2) {
  ade(k1, k2);
  ade(k2, k1);
}
long long ans = 0;
int main() {
  cin >> n >> m;
  memset(p, 0, sizeof(p));
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; i++) scanf("%I64d", &v[i]);
  len = 0;
  int x, y;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
  }
  for (int i = 1; i <= n; i++) a[i] = i;
  sort(a + 1, a + n + 1, cmp);
  memset(pd, 0, sizeof(pd));
  for (int i = 1; i <= n; i++) {
    f[i] = i;
    size[i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    pd[a[i]] = 1;
    for (int j = p[a[i]]; j; j = b[j].n1) {
      int k = b[j].pp;
      if (pd[k]) {
        int xx = gf(a[i]), yy = gf(k);
        if (xx != yy) {
          ans += size[xx] * size[yy] * v[a[i]];
          f[yy] = xx;
          size[xx] += size[yy];
        }
      }
    }
  }
  printf("%.10lf\n", (double)ans / (double)(1ll * n * (n - 1) / 2));
  return 0;
}
