#include <bits/stdc++.h>
using namespace std;
struct edge {
  int u, v, w;
} arr[102400];
int w[102400], fa[102400], cnt[102400];
int gt(int a) { return fa[a] == a ? a : (fa[a] = gt(fa[a])); }
bool comp(const edge &a, const edge &b) { return a.w > b.w; }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", w + i);
    fa[i] = i;
    cnt[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &arr[i].u, &arr[i].v);
    arr[i].w = min(w[arr[i].u], w[arr[i].v]);
  }
  sort(arr, arr + m, comp);
  double ans = 0;
  for (int i = 0; i < m; i++) {
    int u = gt(arr[i].u), v = gt(arr[i].v);
    if (u != v) {
      ans += (double)arr[i].w * cnt[u] * cnt[v];
      cnt[u] += cnt[v];
      fa[v] = u;
    }
  }
  printf("%.6lf\n", ans / ((double)n * (n - 1)) * 2);
  return 0;
}
