#include <bits/stdc++.h>
using namespace std;
long long sz[101000];
int pr[101000];
long double ans = 0;
int get(int x) {
  if (pr[x] == -1)
    return x;
  else
    return pr[x] = get(pr[x]);
}
void d_union(int u, int v, long double vv) {
  u = get(u);
  v = get(v);
  if (u == v) return;
  if (sz[u] < sz[v]) swap(u, v);
  ans += vv * (sz[u] * sz[v]);
  sz[u] = sz[u] + sz[v];
  pr[v] = u;
}
pair<int, pair<int, int> > edg[200000];
int a[101000];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  fill(sz, sz + n, 1);
  memset(pr, -1, sizeof pr);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ans = 0;
  for (int i = 0; i < m; i++) {
    int w, x, y;
    cin >> x >> y;
    x--;
    y--;
    w = min(a[x], a[y]);
    edg[i] = make_pair(w, make_pair(x, y));
  }
  sort(edg, edg + m);
  for (int i = m - 1; i >= 0; i--)
    d_union(edg[i].second.first, edg[i].second.second, edg[i].first);
  cout.precision(16);
  cout << 2 * ans / (n * ((long long)n - 1));
}
