#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e6 + 5;
const long long inf = 1e10;
const long long mod = 1e9 + 7;
long long n, m, x, y;
pair<long long, long long> a[maxN];
vector<long long> ve[maxN];
long long fa[maxN], size[maxN];
long long appear[maxN];
long long find(long long u) {
  if (u == fa[u]) return u;
  return fa[u] = find(fa[u]);
}
void merge(long long u, long long v) {
  fa[u] = v;
  size[v] += size[u];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a + 1, a + 1 + n);
  for (long long i = 1; i <= m; i++) {
    cin >> x >> y;
    ve[x].push_back(y);
    ve[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    fa[i] = i;
    size[i] = 1;
    appear[i] = 0;
  }
  double ans = 0;
  for (long long i = n; i >= 1; i--) {
    long long u = a[i].second;
    appear[u] = 1;
    vector<long long> block;
    block.push_back(1);
    if (ve[u].size() > 0)
      for (long long j = 0; j <= ve[u].size() - 1; j++) {
        long long v = ve[u][j];
        if (!appear[v]) continue;
        if (find(u) != find(v)) {
          block.push_back(size[find(v)]);
          merge(find(u), find(v));
        }
      }
    for (long long j = 0; j <= block.size() - 1; j++) {
      ans += (double)((size[find(u)] - block[j]) * block[j] * a[i].first);
    }
  }
  printf("%.12f", (double)(ans / n / (n - 1)));
  return 0;
}
