#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int u[MAXN], sz[MAXN], arr[MAXN];
long long cnt[MAXN];
vector<int> g[MAXN];
pair<int, int> temp[MAXN];
int root(int a) { return u[a] == a ? a : u[a] = root(u[a]); }
void unin(int a, int b) {
  sz[root(b)] += sz[root(a)];
  u[root(a)] = u[root(b)];
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> arr[i], temp[i] = {arr[i], i};
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  sort(temp + 1, temp + n + 1);
  for (int i = 1; i <= n; i++) u[i] = i, sz[i] = 1;
  for (int ii = n; ii >= 1; ii--) {
    int i = temp[ii].second;
    for (int j : g[i]) {
      if (arr[j] >= arr[i] && root(i) != root(j)) {
        cnt[i] += (long long)sz[root(i)] * sz[root(j)];
        unin(i, j);
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += cnt[i] * arr[i];
  double fans = (double)ans / n / (n - 1) * 2.0;
  cout << setprecision(13) << fixed << fans << '\n';
  return 0;
}
