#include <bits/stdc++.h>
using namespace std;
vector<int> G[123456];
int n, m, weight[123456], rnk[123456], sz[123456], pa[123456];
bool done[123456];
int find(int x) { return pa[x] == x ? x : pa[x] = find(pa[x]); }
void merge(int x, int y) {
  int px = find(x), py = find(y);
  sz[py] += sz[px];
  pa[px] = py;
}
bool cmp(int a, int b) { return weight[a] > weight[b]; }
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> weight[i];
    rnk[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  sort(rnk, rnk + n, cmp);
  for (int i = 0; i < n; i++) {
    pa[i] = i;
    sz[i] = 1;
  }
  double tot = 0;
  for (int i = 0; i < n; i++) {
    int u = rnk[i];
    done[u] = true;
    set<int> st;
    for (size_t j = 0; j < G[u].size(); j++) {
      int v = G[u][j];
      if (done[v]) st.insert(find(v));
    }
    double sum = 0;
    for (set<int>::iterator it = st.begin(); it != st.end(); ++it) {
      sum += sz[*it];
    }
    double ssum = sum;
    for (set<int>::iterator it = st.begin(); it != st.end(); ++it) {
      ssum += ((sum - sz[*it]) * sz[*it] / 2);
    }
    tot += ssum * weight[u];
    for (set<int>::iterator it = st.begin(); it != st.end(); ++it) {
      merge(u, *it);
    }
  }
  printf("%.6lf\n", tot / ((double)n * (n - 1)) * 2);
  return 0;
}
