#include <bits/stdc++.h>
using namespace std;
long long w[100005];
int f[100005];
int cou[100005];
int n, m;
struct sw {
  int l, r;
  long long w;
} E[100005];
int find(int x) {
  if (f[x] != x) f[x] = find(f[x]);
  return f[x];
}
int cmp(const void *a, const void *b) { return ((sw *)b)->w - ((sw *)a)->w; }
void init() {
  for (int i = 1; i <= n; i++) {
    f[i] = i;
    cou[i] = 1;
  }
}
int main(void) {
  scanf("%d%d", &n, &m);
  init();
  for (int i = 1; i <= n; i++) scanf("%I64d", &w[i]);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &E[i].l, &E[i].r);
    E[i].w = min(w[E[i].l], w[E[i].r]);
  }
  qsort(E, m, sizeof(E[0]), cmp);
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    int f1 = find(E[i].l), f2 = find(E[i].r);
    if (f1 != f2) {
      ans += E[i].w * cou[f1] * cou[f2];
      f[f2] = f1;
      cou[f1] += cou[f2];
    }
  }
  long long di = 1LL * n * (n - 1);
  double hehe = ans * 1.0 * 2 / di;
  printf("%.6f\n", hehe);
  return 0;
}
