#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
const int N = 1000100;
int pset[N];
double cnt[N];
int n, m;
double v[N];
int find(int i) { return (pset[i] == i) ? i : (pset[i] = find(pset[i])); }
void union_find(int i, int j) { pset[find(i)] = find(pset[j]); }
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%lf", v + i);
    pset[i] = i;
    cnt[i] = 1;
  }
  vector<pair<double, pair<long long, long long> > > g;
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    g.push_back(make_pair(min(v[a], v[b]), make_pair(a, b)));
  }
  sort(g.rbegin(), g.rend());
  double num = 0.;
  double den = (long long)(n) * (long long)(n - 1);
  for (int i = 0; i < g.size(); ++i) {
    int x = g[i].second.first;
    int y = g[i].second.second;
    double w = g[i].first;
    if (find(x) != find(y)) {
      int p1 = find(x);
      int p2 = find(y);
      double tot = cnt[p1] + cnt[p2];
      double divi = (cnt[p1] * cnt[p2]) / den;
      num += (w * divi);
      union_find(x, y);
      cnt[find(x)] = tot;
    }
  }
  printf("%.10lf\n", (num * 2.0));
  return 0;
}
