#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long MOD = 1e+9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
const long long N = 2e+5 + 7;
long long visit[N] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};
int t = 1;
long long p[N], sz[N], n, m, vis[N];
vector<long long> adj[N];
vector<pair<long long, long long> > v;
void make(long long n) {
  for (int i = 1; i <= n; i++) {
    p[i] = i;
    sz[i] = 1;
  }
}
int find(long long x) { return (p[x] == x) ? x : p[x] = find(p[x]); }
void merge(long long x, long long y) {
  long long a = find(x);
  long long b = find(y);
  if (a != b) {
    if (sz[a] >= sz[b]) swap(a, b);
    p[a] = b;
    sz[b] += sz[a];
  }
}
void MAIN() {
  cin >> n >> m;
  make(n);
  long long x;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    v.push_back({x, i + 1});
  }
  sort((v).begin(), (v).end());
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  long long res = 0;
  for (long long i = n - 1; i >= 0; i--) {
    long long x = v[i].first;
    long long y = v[i].second;
    long long count1 = 0;
    set<long long> set1;
    for (auto it : adj[y]) {
      if (vis[it] == 0) continue;
      long long z = find(it);
      if (set1.find(z) == set1.end()) {
        set1.insert(z);
        res += sz[z] * x;
        count1 += sz[z];
      }
    }
    long long res1 = 0;
    for (auto it : set1) {
      res1 += (count1 - sz[it]) * (sz[it]) * x;
      merge(it, y);
    }
    res += res1 / 2;
    vis[y] = 1;
  }
  cout << (long double)((long double)res / (long double)((n * (n - 1)) / 2));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(10);
  ;
  mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  ;
  while (t--) {
    MAIN();
  }
}
