#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 123;
struct Tedge {
  int v, next;
};
Tedge spaces[maxn * 2];
int tos;
int con[maxn];
void init() {
  tos = 0;
  memset(con, -1, sizeof(con));
}
void addedge(int u, int v) {
  spaces[tos].v = v;
  spaces[tos].next = con[u];
  con[u] = tos++;
}
int father[maxn];
int amount[maxn];
void initf(int n) {
  for (int i = 1; i <= n; ++i) father[i] = i;
}
int getfather(int a) {
  return (father[a] == a) ? (a) : (father[a] = getfather(father[a]));
}
int n, m;
struct Tan {
  int num, idx;
  bool operator<(const Tan& a) const { return num > a.num; }
};
Tan a[maxn];
double summ;
int main() {
  init();
  memset(amount, 0, sizeof(amount));
  scanf("%d%d", &n, &m);
  initf(n);
  int tempc[maxn];
  int tot;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i].num);
    a[i].idx = i;
  }
  sort(a + 1, a + n + 1);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  summ = 0;
  for (int i = 1; i <= n; ++i) {
    int id = a[i].idx;
    amount[id] = 1;
    for (int j = con[id]; j != -1; j = spaces[j].next) {
      int v = spaces[j].v;
      if (amount[v] == 0) continue;
      int nf = getfather(v);
      if (nf == id) continue;
      summ += (amount[id] + 0.0) * (amount[nf] + 0.0) * a[i].num;
      father[nf] = id;
      amount[id] += amount[nf];
    }
  }
  printf("%lf\n", summ * 2.0 / (n * (n - 1.0)));
  return 0;
}
