#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48;
}
int n, m, a[110000];
long long ans;
vector<int> e[110000];
int q[110000];
bool cpr(int x, int y) { return a[x] > a[y]; }
bool vst[110000];
int fa[110000], cnt[110000];
int getf(int x) { return fa[x] == x ? x : fa[x] = getf(fa[x]); }
int nb[110000], ln;
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= (n); ++i) read(a[i]);
  for (int i = 1; i <= (m); ++i) {
    int u, v;
    read(u);
    read(v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  for (int i = 1; i <= (n); ++i) q[i] = i;
  sort(q + 1, q + n + 1, cpr);
  for (int i = 1; i <= (n); ++i) {
    fa[i] = i;
    cnt[i] = 1;
  }
  for (int i = 1; i <= (n); ++i) {
    ln = 0;
    int u(q[i]);
    vst[u] = true;
    for (vector<int>::iterator it = e[u].begin(); it != e[u].end(); ++it)
      if (vst[*it] && getf(*it) != getf(u)) {
        nb[ln++] = getf(*it);
      }
    sort(nb, nb + ln);
    ln = unique(nb, nb + ln) - nb;
    int t(1);
    for (int j = (0); j <= (ln - 1); ++j) {
      t += cnt[nb[j]];
      ans -= 1LL * cnt[nb[j]] * (cnt[nb[j]] - 1) * a[u];
      fa[nb[j]] = fa[u];
      cnt[fa[u]] += cnt[nb[j]];
    }
    ans += 1LL * t * (t - 1) * a[u];
  }
  printf("%.5lf\n", double(ans) / (1. * n * (n - 1)));
  return 0;
}
