#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 17;
const int MOD = 1e9 + 7;
int val[MAXN], exi[MAXN], fth[MAXN], sz[MAXN];
vector<int> G[MAXN];
int fd(int x) { return fth[x] == x ? x : fth[x] = fd(fth[x]); }
bool uni(int x, int y) {
  if (fd(x) == fd(y)) return true;
  ;
  ;
  x = fd(x), y = fd(y);
  fth[y] = x;
  sz[x] += sz[y];
  return false;
}
int main(int argc, char const *argv[]) {
  long long n, m;
  cin >> n >> m;
  vector<pair<int, int> > vec;
  for (int i = 0; i < n; ++i) {
    cin >> val[i];
    vec.push_back({val[i], i});
    fth[i] = i;
    sz[i] = 1;
  }
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  long long ans = 0;
  map<int, int> mp;
  for (int k = 0; k < n; ++k) {
    ;
    int i = vec[k].second;
    ;
    mp.clear();
    long long sum = 1;
    exi[i] = 1;
    for (auto v : G[i]) {
      if (exi[v]) {
        ;
        ;
        ;
        if (!mp.count(fd(v))) {
          mp[fd(v)] += sz[fd(v)];
          sum += sz[fd(v)];
        };
      }
    }
    mp[i] = 1;
    for (auto j : mp) {
      long long tmp = j.second;
      uni(i, j.first);
      ans += tmp * (sum - tmp) * val[i];
    };
  }
  cout << fixed << setprecision(7) << 1.0 * ans / ((n - 1) * n) << endl;
  return 0;
}
