#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T abs(T &a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T min(T &a, T &b) {
  return a < b ? a : b;
}
template <class T>
inline T max(T &a, T &b) {
  return a > b ? a : b;
}
inline void read(int &x) {
  char ch;
  while ((ch = getchar()) && !(ch >= '0' && ch <= '9'))
    ;
  x = ch - '0';
  while ((ch = getchar()) && (ch >= '0' && ch <= '9')) x = x * 10 + ch - '0';
}
struct point {
  int x, y;
  point() {}
  point(int _x, int _y) : x(_x), y(_y) {}
};
const int N = 120000;
struct lj {
  int x, y, w;
} E[N];
int n, m, fa[N], size[N], w[N];
long long ans;
int g_f(int x) { return fa[x] == x ? x : fa[x] = g_f(fa[x]); }
int cmp(lj a, lj b) { return a.w > b.w; }
int main() {
  scanf("%d%d", &n, &m);
  int x, y;
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &E[i].x, &E[i].y);
    E[i].w = min(w[E[i].x], w[E[i].y]);
  }
  for (int i = 1; i <= n; i++) fa[i] = i, size[i] = 1;
  sort(E + 1, E + m + 1, cmp);
  for (int i = 1; i <= m; i++) {
    int p = g_f(E[i].x), q = g_f(E[i].y);
    if (p == q) continue;
    ans += (long long)size[p] * (long long)size[q] * (long long)E[i].w;
    fa[p] = q;
    size[q] += size[p];
  }
  printf("%lf\n", (double)ans * 2 / ((double)n * (double)(n - 1)));
}
