#include <bits/stdc++.h>
using namespace std;
const int maxn = ((int)5e5) + 5;
int n, m;
vector<pair<int, int>> edge;
long long int arr[maxn], sz[maxn];
int dsuPar[maxn];
int rnk[maxn];
int find(int x) {
  if (dsuPar[x] == x) return x;
  return find(dsuPar[x]);
}
long long int sum = 0;
int merge(int x, int y, int w) {
  int parx = find(x);
  int pary = find(y);
  sum += w * (sz[parx]) * (sz[pary]);
  if (rnk[parx] == rnk[pary]) {
    dsuPar[pary] = parx;
    rnk[parx]++;
    sz[parx] += sz[pary];
  } else if (rnk[parx] < rnk[pary]) {
    dsuPar[parx] = pary;
    sz[pary] += sz[parx];
  } else {
    dsuPar[pary] = parx;
    sz[parx] += sz[pary];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) dsuPar[i] = i, sz[i] = 1, cin >> arr[i];
  set<pair<int, int>> edges;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    edges.insert(make_pair(-min(arr[x], arr[y]), i));
    edge.push_back(make_pair(x, y));
  }
  while (!edges.empty()) {
    int w = edges.begin()->first;
    int ed = edges.begin()->second;
    edges.erase(edges.begin());
    if (find(edge[ed].first) != find(edge[ed].second))
      merge(edge[ed].first, edge[ed].second, w);
  }
  sum = -sum;
  double ans = sum / (0.0 + (n * (n - 1.0)) / 2.0);
  cout << fixed << setprecision(9) << ans;
  return 0;
}
