#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
vector<int> a[N];
int p[N], dp[N];
bool mark[N];
pair<int, int> c[N];
int getp(int v) { return (p[v] == v) ? v : p[v] = getp(p[v]); }
int merge(int v, int u) {
  v = getp(v);
  u = getp(u);
  if (u == v) return 0;
  p[u] = v;
  dp[v] += dp[u];
  return dp[u];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> c[i].first;
    p[i] = i;
    dp[i] = 1;
    c[i].second = i;
  }
  sort(c, c + n, greater<pair<int, int> >());
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    u--;
    v--;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  long long ans = 0;
  for (int i = 0, v, u; i < n; i++) {
    v = c[i].second;
    int total = 1;
    mark[v] = true;
    for (int j = 0; j < a[v].size(); j++) {
      u = a[v][j];
      if (!mark[u]) continue;
      int s = merge(v, u);
      ans += (long long)total * s * c[i].first;
      total += s;
    }
  }
  long long tmp = ((long long)n * (n - 1)) / 2;
  cout << fixed << setprecision(6);
  cout << (double)ans / (double)tmp << "\n";
  return 0;
}
