#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000;
int n, m, x, y, z;
int f[maxn], w[maxn], vis[maxn];
std::vector<int> e[maxn];
struct node {
  int x, id;
  bool operator<(const node &p) const { return x > p.x; }
} a[maxn];
long long ans;
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
int main(int argc, char const *argv[]) {
  cin >> n >> m;
  for (int i = 0; i < (n); i++) {
    scanf("%d", &x);
    a[i].x = x, a[i].id = i + 1;
  }
  sort(a, a + n);
  for (int i = 0; i < (m); i++) {
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) f[i] = i, w[i] = 1;
  for (int nn = 0; nn < (n); nn++) {
    int u = a[nn].id;
    long long xx = a[nn].x;
    vis[u] = 1;
    for (int i = 0; i < (e[u].size()); i++)
      if (vis[e[u][i]]) {
        int v = e[u][i];
        int U = find(u), V = find(v);
        if (U != V) {
          ans += xx * w[U] * w[V];
          w[U] += w[V];
          f[V] = U;
        }
      }
  }
  printf("%.6lf\n", (double)ans * 2.0 / (n - 1) / n);
  return 0;
}
