#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e6 + 1;
long long n, m;
pair<long long, int> a[N];
vector<int> adj[N];
long long sz[N];
int p[N];
int find(int x) {
  if (p[x] != x) p[x] = find(p[x]);
  return p[x];
}
long long ans = 0;
long long join(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return 0;
  p[x] = y;
  long long tmp = sz[x] * sz[y];
  sz[y] += sz[x];
  return tmp;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = n; i >= 1; i--) {
    int x = a[i].second;
    sz[x] = 1;
    p[x] = x;
    for (auto y : adj[x]) {
      if (sz[y] == 0) continue;
      long long tmp = join(x, y);
      ans += a[i].first * tmp;
    }
  }
  cout << fixed << setprecision(10) << 2.0 * ans / n / (n - 1) << endl;
}
