#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100001;
const int INF = 100000000;
int n, m, u, v, t;
int N = 100;
vector<pair<int, int> > a;
vector<int> g[MAXN];
int parent[MAXN], sz[MAXN], used[MAXN];
int val;
long long res = 0;
int find_set(int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
void join(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (sz[a] > sz[b]) swap(a, b);
    res += val * 1ll * sz[a] * 1ll * sz[b];
    sz[a] += sz[b];
    parent[b] = a;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    sz[i] = 1;
    parent[i] = i;
    a.push_back(pair<int, int>(t, i));
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    u--;
    v--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  for (int i = 0; i < n; i++) {
    val = a[i].first;
    v = a[i].second;
    used[v] = 1;
    for (int j = 0; j < g[v].size(); j++) {
      int to = g[v][j];
      if (used[to]) join(v, to);
    }
  }
  printf("%.6lf", 2ll * (res / (n * (n - 1.))));
}
