#include <bits/stdc++.h>
using namespace std;
vector<int> Edges[100006];
pair<int, int> V[100006];
int cost[100006], parent[100006], size[100006];
bool vis[100006];
int findparent(int node) {
  if (node == parent[node]) return node;
  return parent[node] = findparent(parent[node]);
}
double find(int N) {
  int i, n, e, x, y, px, py, c;
  double ret = 0;
  memset(vis, false, sizeof(vis));
  vis[V[1].second] = true;
  for (i = 2; i <= N; ++i) {
    n = x = V[i].second;
    px = findparent(x);
    c = V[i].first;
    for (e = 0; e < Edges[n].size(); ++e) {
      y = Edges[n][e];
      py = findparent(y);
      if (px == py || !vis[y]) continue;
      parent[py] = px;
      ret += (double)size[px] * size[py] * c;
      size[px] += size[py];
    }
    vis[n] = true;
  }
  ret *= 2;
  ret /= N;
  ret /= (N - 1);
  return ret;
}
int main() {
  int N, E, i, x, y;
  while (scanf("%d %d", &N, &E) != EOF) {
    for (i = 1; i <= N; ++i) {
      scanf("%d", &cost[i]);
      V[i] = make_pair(cost[i], i);
      Edges[i].clear();
      parent[i] = i, size[i] = 1;
    }
    while (E--) {
      scanf("%d %d", &x, &y);
      Edges[x].push_back(y);
      Edges[y].push_back(x);
    }
    sort(V + 1, V + 1 + N);
    reverse(V + 1, V + 1 + N);
    printf("%.6lf\n", find(N));
  }
  return 0;
}
