#include <bits/stdc++.h>
using namespace std;
const long long M = 1e5 + 10;
long long ans;
long long par[M], size[M], a[M], x[M], y[M];
pair<long long, long long> eg[M];
int root(long long u) {
  if (par[u] == -1) return u;
  return par[u] = root(par[u]);
}
void merge(long long i) {
  long long k = eg[i].second;
  long long w = eg[i].first;
  long long u = x[k];
  long long v = y[k];
  u = root(u);
  v = root(v);
  if (u == v) return;
  if (size[u] < size[v]) swap(u, v);
  ans += (long long)size[u] * (long long)size[v] * (long long)w;
  par[v] = u;
  size[u] += size[v];
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
    eg[i] = {min(a[x[i]], a[y[i]]), i};
  }
  fill(par, par + M, -1);
  fill(size, size + M, 1);
  sort(eg, eg + m);
  reverse(eg, eg + m);
  for (long long i = 0; i < m; i++) {
    merge(i);
  }
  cout << setprecision(9) << fixed << double(ans) / double(n * (n - 1) / 2);
}
