#include <bits/stdc++.h>
using namespace std;
const int L = 100100;
struct point {
  int x, n;
} a[L];
struct edge {
  int y, n;
} e[2 * L];
int h[L], tot;
int f[L], s[L], b[L], n, m;
long long ans;
void ins(int x, int y) {
  e[++tot].y = y;
  e[tot].n = h[x];
  h[x] = tot;
}
int cmp(const void *a, const void *b) {
  return (*(point *)b).x - (*(point *)a).x;
}
void init(void) {
  cin >> n >> m;
  int i, x, y;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i].x);
    b[i] = a[i].x;
    a[i].n = i;
    s[i] = 1;
  }
  qsort(a + 1, n, sizeof(a[0]), cmp);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    ins(x, y);
    ins(y, x);
  }
}
int find(int x) { return !f[x] ? x : f[x] = find(f[x]); }
void work(void) {
  int i, j, k, x, y, rx, ry;
  double tmp;
  for (j = 1; j <= n; j++) {
    x = a[j].n;
    for (i = h[x]; i; i = e[i].n)
      if ((rx = find(x)) != (ry = find(y = e[i].y)))
        if (b[rx] <= b[ry]) {
          ans += (long long)a[j].x * (long long)s[rx] * (long long)s[ry];
          s[rx] += s[ry];
          f[ry] = rx;
        }
  }
  tmp = (double)ans * 2.0 / (double)n / (double)(n - 1);
  printf("%.6lf\n", tmp);
}
int main(void) {
  init();
  work();
  return 0;
}
