#include <bits/stdc++.h>
using namespace std;
int N, M, A[100005], fa[100005], num[100005];
long long Ans = 0;
struct node {
  int x, y, c;
} E[100005];
inline bool cmp(node a, node b) { return a.c > b.c; }
inline int get(int u) { return (fa[u] == u) ? u : fa[u] = get(fa[u]); }
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) scanf("%d", &A[i]), fa[i] = i, num[i] = 1;
  for (int i = 1; i <= M; i++) {
    scanf("%d%d", &E[i].x, &E[i].y);
    E[i].c = ((A[E[i].x]) < (A[E[i].y]) ? (A[E[i].x]) : (A[E[i].y]));
  }
  sort(E + 1, E + M + 1, cmp);
  for (int i = 1; i <= M; i++) {
    int x = E[i].x, y = E[i].y;
    int fx = get(x), fy = get(y);
    if (fx == fy) continue;
    Ans = Ans + 1ll * num[fx] * num[fy] * E[i].c;
    fa[fx] = fy;
    num[fy] += num[fx];
  }
  printf("%.6lf\n", Ans * 2.0 / (1ll * N * (N - 1)));
  return 0;
}
