#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
int N, M, f[MAXN], a[MAXN], id[MAXN], size[MAXN];
vector<int> g[MAXN], gg[MAXN];
int visit[MAXN], v[MAXN], tmp[MAXN];
long long ans;
bool cmp(int x, int y) { return a[x] > a[y]; }
inline int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
void addedge(int x, int y) {
  g[x].push_back(y);
  g[y].push_back(x);
}
int getfather(int x) {
  if (x == f[x])
    return x;
  else
    return f[x] = getfather(f[x]);
}
inline void merge(int x, int y) {
  x = getfather(x);
  y = getfather(y);
  if (x != y) {
    f[x] = y;
    size[y] += size[x];
  }
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= N; ++i) {
    id[i] = f[i] = i;
    size[i] = 1;
  }
  for (int i = 1, x, y; i <= M; ++i) {
    scanf("%d%d", &x, &y);
    gg[x].push_back(y);
    gg[y].push_back(x);
  }
  sort(id + 1, id + N + 1, cmp);
  for (int tt = 1; tt <= N; ++tt) {
    int now = id[tt];
    v[now] = 1;
    sort(gg[now].begin(), gg[now].end(), cmp);
    int sum = 0;
    int tot = 0;
    for (int i = 0; i < gg[now].size(); ++i) {
      int x = gg[now][i];
      if (v[x]) {
        int y = getfather(x);
        if (visit[y] != tt) {
          ans += (long long)size[y] * a[now] * 2LL;
          ans += (long long)sum * size[y] * a[now] * 2LL;
          sum += size[y];
          addedge(now, x);
          visit[y] = tt;
          tmp[++tot] = x;
        }
      }
    }
    for (int i = 1; i <= tot; ++i) {
      merge(now, tmp[i]);
    }
  }
  double res = 0;
  res = (double)ans / (double)N;
  res = (double)res / (double)(N - 1);
  printf("%.6f\n", res);
  return 0;
}
