#include <bits/stdc++.h>
using namespace std;
int v[100005], chk[100005];
int n, m, an;
struct Data {
  int x, v;
  Data(int x = 0, int v = 0) : x(x), v(v) {}
} D[100005], tp;
bool operator<(const Data &a, const Data &b) { return a.v < b.v; }
priority_queue<Data> q;
vector<int> con[100005], dcon[100005];
long long a[100005];
int root[100005], cnt[100005];
int find_root(int x) {
  if (root[x] == x) return x;
  return root[x] = find_root(root[x]);
}
int main() {
  int x, y;
  int i, k, j;
  cin >> n >> m;
  int mx(-1), p(-1);
  for (i = 0; i < n; i++) {
    scanf("%d", v + i);
    if (v[i] > mx) {
      mx = v[i];
      p = i;
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    x--, y--;
    con[x].push_back(y);
    con[y].push_back(x);
  }
  q.push(Data(p, v[p]));
  chk[p] = 1;
  while (!q.empty()) {
    tp = q.top(), q.pop();
    x = tp.x;
    for (i = 0; i < con[x].size(); i++) {
      y = con[x][i];
      if (chk[y]) continue;
      q.push(Data(y, v[y]));
      chk[y] = 1;
      dcon[x].push_back(y);
      dcon[y].push_back(x);
    }
  }
  for (i = 0; i < n; i++) D[i] = Data(i, v[i]);
  sort(D, D + n), reverse(D, D + n);
  memset(root, -1, sizeof(root));
  long long ans(0LL), vv;
  for (i = 0; i < n; i++) {
    x = D[i].x, vv = D[i].v, an = 0;
    for (j = 0; j < dcon[x].size(); j++) {
      y = dcon[x][j];
      if (root[y] == -1) continue;
      p = find_root(y);
      root[p] = x;
      if (cnt[p]) a[an++] = cnt[p];
    }
    if (an == 0) {
      root[x] = x;
      cnt[x] = 1;
      continue;
    }
    long long S = 0;
    for (j = 0; j < an; j++) S += a[j];
    ans += 2LL * S * vv;
    for (j = 0; j < an; j++) ans += a[j] * (S - a[j]) * vv;
    root[x] = x;
    cnt[x] = S + 1;
  }
  printf("%.10lf\n", ans / (1.0 * n * (n - 1)));
}
