#include <bits/stdc++.h>
using namespace std;
long long u[108000], a[108000], sz[108000];
long long n, m, x, y;
long long res;
long long r(long long x) {
  if (u[x] == x) return x;
  return u[x] = r(u[x]);
}
void unin(long long a, long long b) {
  a = r(a);
  b = r(b);
  u[a] = b;
}
int main() {
  for (long long i = 0; i < 108000; i++) u[i] = i, sz[i] = 1;
  vector<pair<long long, pair<long long, long long> > > edge;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    x--, y--;
    edge.push_back(pair<long long, pair<long long, long long> >(
        min(a[x], a[y]), pair<long long, long long>(x, y)));
  }
  sort(edge.begin(), edge.end());
  while (!edge.empty()) {
    pair<long long, long long> tmp = edge.back().second;
    long long cost = edge.back().first;
    edge.pop_back();
    long long x = tmp.first, y = tmp.second;
    x = r(x), y = r(y);
    if (x == y) continue;
    res += cost * sz[x] * sz[y];
    long long nextsz = sz[x] + sz[y];
    unin(x, y);
    x = r(x);
    sz[x] = nextsz;
  }
  res *= 2;
  printf("%.9lf\n", (double)res / (n * (n - 1)));
  return 0;
}
