#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100010];
vector<int> e[100010];
bool vis[100010];
int par[100010], rk[100010], siz[100010];
pair<int, int> v[100010];
int find(int p) {
  if (p == par[p]) return p;
  par[p] = find(par[p]);
  return par[p];
}
void merge(int a, int b) {
  a = find(a);
  b = find(b);
  if (a == b) return;
  if (rk[a] > rk[b]) {
    par[b] = a;
    siz[a] += siz[b];
  } else if (rk[a] < rk[b]) {
    par[a] = b;
    siz[b] += siz[a];
  } else {
    par[b] = a;
    siz[a] += siz[b];
    rk[a]++;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    v[i] = make_pair(a[i], i);
  }
  sort(v, v + n);
  reverse(v, v + n);
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rk[i] = 0;
    siz[i] = 1;
  }
  long long res = 0;
  for (int k = 0; k < n; k++) {
    int i = v[k].second;
    vis[i] = 1;
    int tot = 1;
    for (int j = 0; j < e[i].size(); j++) {
      if (vis[e[i][j]]) {
        int x = find(e[i][j]);
        if (x == find(i)) continue;
        res += (long long)siz[x] * tot * a[i];
        tot += siz[x];
        merge(i, x);
      }
    }
  }
  printf("%.12f\n", 2 * (double)res / n / (n - 1));
  return 0;
}
