#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 100 + 2;
int n, m, parent[maxn], r[maxn];
long long a[maxn], javab = 0, dp[maxn];
vector<pair<long long, pair<int, int> > > v;
int par(int x) {
  if (x == parent[x]) return x;
  return parent[x] = par(parent[x]);
}
void merge(int x, int y, long long z) {
  x = par(x);
  y = par(y);
  if (x == y) return;
  if (r[x] < r[y]) swap(x, y);
  javab += (long long)r[x] * (long long)r[y] * z;
  r[x] += r[y];
  parent[y] = x;
}
int main() {
  int x, y;
  long long z;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    v.push_back(make_pair(min(a[x], a[y]), make_pair(x, y)));
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    parent[i] = i;
    r[i] = 1;
  }
  for (int i = 0; i < (int)v.size(); i++) {
    x = v[i].second.first;
    y = v[i].second.second;
    z = v[i].first;
    merge(x, y, z);
  }
  double w = (double)(javab * 2) / (double)n;
  w /= (double)(n - 1);
  cout << fixed << setprecision(6) << w << endl;
  return 0;
}
